summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rtp_profile_amrwb.cc29
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;