diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-12-04 14:02:55 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-12-04 14:02:55 +0100 |
commit | 4c3faee9aded6e88af902cef33c3bd43f3475c35 (patch) | |
tree | e70901a901fb52a74bfbb3a0e4a616b5ec499daf /src | |
parent | e1e527d61f619832c82f293b9658820b7c5bbf59 (diff) |
Force even number of frames in each packet (unless 1) for robust stereo frame interleaving on package loss. Remove some printf's.
Diffstat (limited to 'src')
-rw-r--r-- | src/rtp_profile_amrwb.cc | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/rtp_profile_amrwb.cc b/src/rtp_profile_amrwb.cc index f83b3c3..b376cb9 100644 --- a/src/rtp_profile_amrwb.cc +++ b/src/rtp_profile_amrwb.cc @@ -138,7 +138,7 @@ int profile_amrwb_pack(struct lrtp_profile_t *profile, size_t cpsz = inputsize; - printf("cpsz: %d\n", cpsz); + //printf("cpsz: %d\n", cpsz); size_t num_frames = cpsz / frame_size; @@ -148,7 +148,14 @@ int profile_amrwb_pack(struct lrtp_profile_t *profile, return -1; } - if(num_frames > max_num_frames) num_frames = max_num_frames; + if(num_frames > max_num_frames) { + num_frames = max_num_frames; + } + + // Make sure num_frames > 1 is an even number (don't split stereo frames) + if(num_frames != 1) num_frames = (num_frames / 2) * 2; + + cpsz = num_frames * frame_size; // Actually consumed bytes. char *payload = (char*)malloc(MAX_RTP_PAYLOAD_SIZE); @@ -189,17 +196,24 @@ int profile_amrwb_pack(struct lrtp_profile_t *profile, frame_offset += frame_size; payload_size += frameheader_size + frame_size; } - + /* + printf("---------------------------------------- New packet:\n"); + printf("payload (pack):\n"); + for(int i = 0; i < payload_size; i++) { + printf("%02x ", (unsigned char)payload[i]); + } + printf("\n"); + */ //size_t payload_size = cmr_size + num_frames*(frame_size + frameheader_size); rtp.setPayload(payload, payload_size); rtp.setValid(true); - + /* printf("payload (pack):\n"); for(int i = 0; i < payload_size; i++) { printf("%02x ", (unsigned char)payload[i]); } printf("\n"); - + */ free(payload); return cpsz; @@ -213,14 +227,14 @@ int profile_amrwb_unpack(struct lrtp_profile_t *profile, size_t size = rtp.payloadSize(); const char *payload = rtp.payloadData(); - + /* printf("---------------------------------------- New packet:\n"); printf("payload (unpack):\n"); for(int i = 0; i < size; i++) { printf("%02x ", (unsigned char)payload[i]); } printf("\n"); - + */ // Read CMR: size_t cmr_size = 1; char CMR = payload[0]; @@ -256,6 +270,7 @@ int profile_amrwb_unpack(struct lrtp_profile_t *profile, memcpy(buf, frame_data, frame_size); of->data = buf; + //printf("push amrwb frame (size: %d)\n", of->size); framelist.push_back(of); if(is_last_frame(frame_toc)) return 0; |