diff --git a/src/channels/chan_voicemngr.c b/src/channels/chan_voicemngr.c
index 6a9e2144e76f2c4a235f637f8c5abead9ed4aa50..6a5f751f2ede227cbba4a51a2dfe4a7cabfb496a 100644
--- a/src/channels/chan_voicemngr.c
+++ b/src/channels/chan_voicemngr.c
@@ -1310,30 +1310,30 @@ static int brcm_answer(struct ast_channel *ast)
 */
 static char* brcm_get_codec_string(int id) {
 	switch (id) {
-			case PCMA:		return "alaw"; break;
-			case PCMU:		return "ulaw"; break;
-			case G723:		return "g723.1"; break;
-			case G726:		return "g726"; break;
-			case G729:		return "g729"; break;
-			case G722:		return "g722"; break;
-			case CN:        	return "cn"; break;
-			case -1:		return "none set"; break;
-			default: 		return "unknown id"; break;
+		case RTP_PT_PCMA: return "alaw"; break;
+		case RTP_PT_PCMU: return "ulaw"; break;
+		case RTP_PT_G723: return "g723.1"; break;
+		case RTP_PT_G726: return "g726"; break;
+		case RTP_PT_G729: return "g729"; break;
+		case RTP_PT_G722: return "g722"; break;
+		case RTP_PT_CN:   return "cn"; break;
+		case -1:          return "none set"; break;
+		default:          return "unknown id"; break;
 	}
 }
 
 static int brcm_classify_rtp_packet(int payload_type) {
 
 	switch (payload_type) {
-		case PCMU: 	return BRCM_AUDIO;
-		case G726: 	return BRCM_AUDIO;
-		case G723: 	return BRCM_AUDIO;
-		case PCMA: 	return BRCM_AUDIO;
-		case G729: 	return BRCM_AUDIO;
-		case G722: 	return BRCM_AUDIO;
-		case CN: 	return BRCM_AUDIO;
-		case RTCP_SR: 	return BRCM_RTCP_SR;
-		case RTCP_RR: 	return BRCM_RTCP_RR;
+		case RTP_PT_PCMU: return BRCM_AUDIO;
+		case RTP_PT_G726: return BRCM_AUDIO;
+		case RTP_PT_G723: return BRCM_AUDIO;
+		case RTP_PT_PCMA: return BRCM_AUDIO;
+		case RTP_PT_G729: return BRCM_AUDIO;
+		case RTP_PT_G722: return BRCM_AUDIO;
+		case RTP_PT_CN:   return BRCM_AUDIO;
+		case RTCP_SR:     return BRCM_RTCP_SR;
+		case RTCP_RR:     return BRCM_RTCP_RR;
 		default:
 			ast_verbose("Unknown rtp packet payload_type %d\n", payload_type);
 			return BRCM_UNKNOWN;
@@ -1343,20 +1343,20 @@ static int brcm_classify_rtp_packet(int payload_type) {
 static int map_ast_codec_id_to_rtp(const struct ast_format *astcodec)
 {
 	if (ast_format_cmp(astcodec, ast_format_alaw) == AST_FORMAT_CMP_EQUAL) {
-		return PCMA;
+		return RTP_PT_PCMA;
 	} else if (ast_format_cmp(astcodec, ast_format_ulaw) == AST_FORMAT_CMP_EQUAL) {
-		return PCMU;
+		return RTP_PT_PCMU;
 	} else if (ast_format_cmp(astcodec, ast_format_g722) == AST_FORMAT_CMP_EQUAL) {
-		return G722;
+		return RTP_PT_G722;
 	} else if (ast_format_cmp(astcodec, ast_format_g723) == AST_FORMAT_CMP_EQUAL) {
-		return G723;
+		return RTP_PT_G723;
 	} else if (ast_format_cmp(astcodec, ast_format_g729) == AST_FORMAT_CMP_EQUAL) {
-		return G729;
+		return RTP_PT_G729;
 	} else if (ast_format_cmp(astcodec, ast_format_g726) == AST_FORMAT_CMP_EQUAL) {
-		return G726;
+		return RTP_PT_G726;
 	} else {
 		ast_verbose("Unknown asterisk format/codec\n");
-		return PCMA;
+		return RTP_PT_PCMA;
 	}
 }
 
@@ -1415,10 +1415,10 @@ static int brcm_write(struct ast_channel *ast, struct ast_frame *frame)
 		pvt_lock(sub->parent, "TELCHAN write frame");
 
 		/* generate the rtp header */
-		brcm_generate_rtp_packet(sub, ap->rtp, CN, 0, 0, frame->seqno);
+		brcm_generate_rtp_packet(sub, ap->rtp, RTP_PT_CN, 0, 0, frame->seqno);
 
 		/* set rtp payload type sent to voicemngr */
-		sub->codec = CN;
+		sub->codec = RTP_PT_CN;
 
 		//ast_mutex_unlock(&sub->parent->lock);
 		pvt_unlock(sub->parent);
@@ -2649,12 +2649,12 @@ static void send_outgoing_dtmf(struct ast_channel *owner, char dtmf_button, int
 /* Get asterisk format from RTP payload type */
 static struct ast_format *map_rtptype_to_format(uint8_t payload_type) {
 	switch (payload_type) {
-	case PCMU: return ast_format_ulaw;
-	case PCMA: return ast_format_alaw;
-	case G722: return ast_format_g722;
-	case G723: return ast_format_g723;
-	case G726: return ast_format_g726;
-	case G729: return ast_format_g729;
+	case RTP_PT_PCMU: return ast_format_ulaw;
+	case RTP_PT_PCMA: return ast_format_alaw;
+	case RTP_PT_G722: return ast_format_g722;
+	case RTP_PT_G723: return ast_format_g723;
+	case RTP_PT_G726: return ast_format_g726;
+	case RTP_PT_G729: return ast_format_g729;
 	default:
 		ast_debug(1, "Warning: unknown RTP payload_type %u is received. Treated it as PCMU\n", payload_type);
 		return ast_format_ulaw;
@@ -2664,13 +2664,17 @@ static struct ast_format *map_rtptype_to_format(uint8_t payload_type) {
 /* Handle audio packets from voicemngr. */
 static void audio_packet_handler(pe_packet_t *p) {
 	struct brcm_subchannel *sub;
-	int rtp_packet_type  = BRCM_UNKNOWN, drop_frame = 0;
+	int packet_type  = BRCM_UNKNOWN, drop_frame = 0;
 	audio_packet_t *ap = (audio_packet_t *)p->data;
 	uint8_t payload_type = ap->rtp[1];
 	struct ast_frame frame = { .src = "TELCHAN", };
 	struct brcm_pvt *pvt;
 
-	rtp_packet_type = brcm_classify_rtp_packet(payload_type);
+	// Clear the RTP marker bit
+	if ((payload_type & RTP_MARKER_BIT) && payload_type < RTCP_SR)
+		payload_type &= (~RTP_MARKER_BIT);
+
+	packet_type = brcm_classify_rtp_packet(payload_type);
 	pvt = brcm_get_pvt_from_lineid(iflist, ap->line);
 	sub = brcm_get_active_subchannel(pvt);
 	if (!pvt || !sub) {
@@ -2689,12 +2693,12 @@ static void audio_packet_handler(pe_packet_t *p) {
 
 	// We seem to get packets from DSP even if connection is muted (perhaps muting only affects packet callback).
 	// Drop packets if subchannel is on hold. Handle rtp packet according to classification.
-	if (sub->channel_state != ONHOLD && rtp_packet_type == BRCM_AUDIO && (ap->rtp[0] & 0x80) && ap->rtp_size) {
+	if (sub->channel_state != ONHOLD && packet_type == BRCM_AUDIO && (ap->rtp[0] & 0x80) && ap->rtp_size) {
 		frame.frametype = AST_FRAME_VOICE;
 		frame.offset = 0;
 		frame.data.ptr = ap->rtp + 12;
 		frame.datalen = ap->rtp_size - 12;
-		if (payload_type == CN) {
+		if (payload_type == RTP_PT_CN) {
 			frame.frametype = AST_FRAME_CNG;
 			frame.subclass.integer = ap->rtp[12];
 		} else {
@@ -2704,13 +2708,13 @@ static void audio_packet_handler(pe_packet_t *p) {
 				frame.samples = ast_codec_samples_count(&frame);
 			}
 		}
-	} else if (rtp_packet_type == BRCM_RTCP_SR || rtp_packet_type == BRCM_RTCP_RR) {
+	} else if (packet_type == BRCM_RTCP_SR || packet_type == BRCM_RTCP_RR) {
 		frame.frametype = AST_FRAME_RTCP;
 		frame.data.ptr = ap->rtp;
 		frame.datalen = ap->rtp_size;
-		frame.subclass.integer = (rtp_packet_type == BRCM_RTCP_SR ? RTCP_SR : RTCP_RR);
+		frame.subclass.integer = (packet_type == BRCM_RTCP_SR ? RTCP_SR : RTCP_RR);
 	} else {
-		//ast_debug(5, "Dropping RTP frame of type %d.\n", rtp_packet_type);
+		//ast_debug(5, "Dropping RTP frame of type %d.\n", packet_type);
 		drop_frame=1;
 		//pvt_unlock(sub->parent);
 	}
diff --git a/src/channels/chan_voicemngr.h b/src/channels/chan_voicemngr.h
index 7f35aa457a785dcbc9eb527ea845434e5990ed62..a4cd44db272b2de1b268e16dbd4460372ace6a2e 100644
--- a/src/channels/chan_voicemngr.h
+++ b/src/channels/chan_voicemngr.h
@@ -14,21 +14,25 @@
 
 #define TIMEMSEC 1000
 
-#define PCMU 0
-#define G726 2
-#define G723 4
-#define PCMA 8
-#define G729 18
-#define G722 9
-#define DTMF_PAYLOAD 101
-#define DTMF 128
+// RTP payload type
+#define RTP_PT_PCMU 0
+#define RTP_PT_G726 2
+#define RTP_PT_G723 4
+#define RTP_PT_PCMA 8
+#define RTP_PT_G722 9
+#define RTP_PT_CN   13
+#define RTP_PT_G729 18
+#define RTP_PT_DTMF 101
+
+// Marker bit
+#define RTP_MARKER_BIT  (1<<7)
+
+// RTCP packet type
 #define RTCP_SR      200
 #define RTCP_RR      201
 #define RTCP_SDES    202
 #define RTCP_XR      207
 
-#define CN 13
-
 #define NOT_INITIALIZED -1
 //#define EPSTATUS_DRIVER_ERROR -1
 #define MAX_NUM_LINEID 30