mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-22 20:56:39 +00:00
Add pass through support for Opus and VP8; Opus format attribute negotiation
This patch adds pass through support for Opus and VP8. That includes: * Format attribute negotiation for Opus. Note that unlike some other codecs, the draft RFC specifies having spaces delimiting the attributes in addition to ';', so you have "attra=X; attrb=Y". This broke the attribute parsing in chan_sip, so a small tweak was also included in this patch for that. * A format attribute negotiation module for Opus, res_format_attr_opus * Fast picture update for VP8. Since VP8 uses a different RTCP packet number than FIR, this really is specific to VP8 at this time. Note that the format attribute negotiation in res_pjsip_sdp_rtp was written by mjordan. The rest of this patch was written completely by Lorenzo Miniero. Review: https://reviewboard.asterisk.org/r/2723/ (closes issue ASTERISK-21981) Reported by: Tzafrir Cohen patches: asterisk_opus+vp8_passthrough_20130718.patch uploaded by lminiero (License 6518) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397526 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -802,6 +802,8 @@ struct ast_format *ast_best_codec(struct ast_format_cap *cap, struct ast_format
|
||||
AST_FORMAT_SPEEX32,
|
||||
AST_FORMAT_SPEEX16,
|
||||
AST_FORMAT_SPEEX,
|
||||
/*! Opus */
|
||||
AST_FORMAT_OPUS,
|
||||
/*! SILK is pretty awesome. */
|
||||
AST_FORMAT_SILK,
|
||||
/*! CELT supports crazy high sample rates */
|
||||
|
@@ -430,6 +430,9 @@ uint64_t ast_format_id_to_old_bitfield(enum ast_format_id id)
|
||||
/*! SpeeX Wideband (16kHz) Free Compression */
|
||||
case AST_FORMAT_SPEEX16:
|
||||
return (1ULL << 33);
|
||||
/*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */
|
||||
case AST_FORMAT_OPUS:
|
||||
return (1ULL << 34);
|
||||
/*! Raw mu-law data (G.711) */
|
||||
case AST_FORMAT_TESTLAW:
|
||||
return (1ULL << 47);
|
||||
@@ -449,6 +452,9 @@ uint64_t ast_format_id_to_old_bitfield(enum ast_format_id id)
|
||||
/*! MPEG4 Video */
|
||||
case AST_FORMAT_MP4_VIDEO:
|
||||
return (1ULL << 22);
|
||||
/*! VP8 Video */
|
||||
case AST_FORMAT_VP8:
|
||||
return (1ULL << 23);
|
||||
|
||||
/*! JPEG Images */
|
||||
case AST_FORMAT_JPEG:
|
||||
@@ -532,6 +538,9 @@ struct ast_format *ast_format_from_old_bitfield(struct ast_format *dst, uint64_t
|
||||
/*! SpeeX Wideband (16kHz) Free Compression */
|
||||
case (1ULL << 33):
|
||||
return ast_format_set(dst, AST_FORMAT_SPEEX16, 0);
|
||||
/*! Opus audio (8kHz, 16kHz, 24kHz, 48Khz) */
|
||||
case (1ULL << 34):
|
||||
return ast_format_set(dst, AST_FORMAT_OPUS, 0);
|
||||
/*! Raw mu-law data (G.711) */
|
||||
case (1ULL << 47):
|
||||
return ast_format_set(dst, AST_FORMAT_TESTLAW, 0);
|
||||
@@ -551,6 +560,9 @@ struct ast_format *ast_format_from_old_bitfield(struct ast_format *dst, uint64_t
|
||||
/*! MPEG4 Video */
|
||||
case (1ULL << 22):
|
||||
return ast_format_set(dst, AST_FORMAT_MP4_VIDEO, 0);
|
||||
/*! VP8 Video */
|
||||
case (1ULL << 23):
|
||||
return ast_format_set(dst, AST_FORMAT_VP8, 0);
|
||||
|
||||
/*! JPEG Images */
|
||||
case (1ULL << 16):
|
||||
@@ -782,6 +794,9 @@ int ast_format_rate(const struct ast_format *format)
|
||||
return samplerate;
|
||||
}
|
||||
}
|
||||
/* Opus */
|
||||
case AST_FORMAT_OPUS:
|
||||
return 48000;
|
||||
default:
|
||||
return 8000;
|
||||
}
|
||||
@@ -1067,6 +1082,10 @@ static int format_list_init(void)
|
||||
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR48, 0), "slin48", 48000, "16 bit Signed Linear PCM (48kHz)", 960, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (48kHz) */
|
||||
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR96, 0), "slin96", 96000, "16 bit Signed Linear PCM (96kHz)", 1920, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (96kHz) */
|
||||
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR192, 0), "slin192", 192000, "16 bit Signed Linear PCM (192kHz)", 3840, 10, 70, 10, 20, AST_SMOOTHER_FLAG_BE, 0);/*!< Signed linear (192kHz) */
|
||||
/* Opus (FIXME: real min is 3/5/10, real max is 120...) */
|
||||
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), "opus", 48000, "Opus Codec", 10, 20, 60, 20, 20, 0, 0); /*!< codec_opus.c */
|
||||
/* VP8 (passthrough) */
|
||||
format_list_add_static(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), "vp8", 0, "VP8 Video", 0, 0, 0, 0 ,0 ,0, 0); /*!< Passthrough support, see format_h263.c */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1097,9 +1097,13 @@ int ast_codec_get_samples(struct ast_frame *f)
|
||||
return 160;
|
||||
}
|
||||
case AST_FORMAT_CELT:
|
||||
/* TODO The assumes 20ms delivery right now, which is incorrect */
|
||||
/* TODO This assumes 20ms delivery right now, which is incorrect */
|
||||
samples = ast_format_rate(&f->subclass.format) / 50;
|
||||
break;
|
||||
case AST_FORMAT_OPUS:
|
||||
/* TODO This assumes 20ms delivery right now, which is incorrect */
|
||||
samples = 960;
|
||||
break;
|
||||
default:
|
||||
ast_log(LOG_WARNING, "Unable to calculate samples for format %s\n", ast_getformatname(&f->subclass.format));
|
||||
}
|
||||
|
@@ -1977,6 +1977,9 @@ int ast_rtp_engine_init()
|
||||
set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN7, 0), 0, "audio", "G7221", 16000);
|
||||
set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_SIREN14, 0), 0, "audio", "G7221", 32000);
|
||||
set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_G719, 0), 0, "audio", "G719", 48000);
|
||||
/* Opus and VP8 */
|
||||
set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0, "audio", "opus", 48000);
|
||||
set_next_mime_type(ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0, "video", "VP8", 90000);
|
||||
|
||||
/* Define the static rtp payload mappings */
|
||||
add_static_payload(0, ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0), 0);
|
||||
@@ -2018,6 +2021,9 @@ int ast_rtp_engine_init()
|
||||
add_static_payload(118, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR16, 0), 0); /* 16 Khz signed linear */
|
||||
add_static_payload(119, ast_format_set(&tmpfmt, AST_FORMAT_SPEEX32, 0), 0);
|
||||
add_static_payload(121, NULL, AST_RTP_CISCO_DTMF); /* Must be type 121 */
|
||||
/* Opus and VP8 */
|
||||
add_static_payload(100, ast_format_set(&tmpfmt, AST_FORMAT_VP8, 0), 0);
|
||||
add_static_payload(107, ast_format_set(&tmpfmt, AST_FORMAT_OPUS, 0), 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user