Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
c136a813
Commit
c136a813
authored
Oct 08, 2012
by
Martin Storsjö
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rtp: Support packetization/depacketization of opus
Signed-off-by:
Martin Storsjö
<
martin@martin.st
>
parent
e04826c3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
rtpdec.c
libavformat/rtpdec.c
+7
-0
rtpenc.c
libavformat/rtpenc.c
+19
-0
sdp.c
libavformat/sdp.c
+4
-0
No files found.
libavformat/rtpdec.c
View file @
c136a813
...
...
@@ -55,6 +55,12 @@ static RTPDynamicProtocolHandler speex_dynamic_handler = {
.
codec_id
=
AV_CODEC_ID_SPEEX
,
};
static
RTPDynamicProtocolHandler
opus_dynamic_handler
=
{
.
enc_name
=
"opus"
,
.
codec_type
=
AVMEDIA_TYPE_AUDIO
,
.
codec_id
=
AV_CODEC_ID_OPUS
,
};
/* statistics functions */
static
RTPDynamicProtocolHandler
*
RTPFirstDynamicPayloadHandler
=
NULL
;
...
...
@@ -85,6 +91,7 @@ void av_register_rtp_dynamic_payload_handlers(void)
ff_register_dynamic_payload_handler
(
&
ff_qcelp_dynamic_handler
);
ff_register_dynamic_payload_handler
(
&
realmedia_mp3_dynamic_handler
);
ff_register_dynamic_payload_handler
(
&
speex_dynamic_handler
);
ff_register_dynamic_payload_handler
(
&
opus_dynamic_handler
);
ff_register_dynamic_payload_handler
(
&
ff_ms_rtp_asf_pfv_handler
);
ff_register_dynamic_payload_handler
(
&
ff_ms_rtp_asf_pfa_handler
);
...
...
libavformat/rtpenc.c
View file @
c136a813
...
...
@@ -77,6 +77,7 @@ static int is_supported(enum AVCodecID id)
case
AV_CODEC_ID_ILBC
:
case
AV_CODEC_ID_MJPEG
:
case
AV_CODEC_ID_SPEEX
:
case
AV_CODEC_ID_OPUS
:
return
1
;
default:
return
0
;
...
...
@@ -186,6 +187,16 @@ static int rtp_write_header(AVFormatContext *s1)
* 8000, even if the sample rate is 16000. See RFC 3551. */
avpriv_set_pts_info
(
st
,
32
,
1
,
8000
);
break
;
case
AV_CODEC_ID_OPUS
:
if
(
st
->
codec
->
channels
>
2
)
{
av_log
(
s1
,
AV_LOG_ERROR
,
"Multistream opus not supported in RTP
\n
"
);
goto
fail
;
}
/* The opus RTP RFC says that all opus streams should use 48000 Hz
* as clock rate, since all opus sample rates can be expressed in
* this clock rate, and sample rate changes on the fly are supported. */
avpriv_set_pts_info
(
st
,
32
,
1
,
48000
);
break
;
case
AV_CODEC_ID_ILBC
:
if
(
st
->
codec
->
block_align
!=
38
&&
st
->
codec
->
block_align
!=
50
)
{
av_log
(
s1
,
AV_LOG_ERROR
,
"Incorrect iLBC block size specified
\n
"
);
...
...
@@ -525,6 +536,14 @@ static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
case
AV_CODEC_ID_MJPEG
:
ff_rtp_send_jpeg
(
s1
,
pkt
->
data
,
size
);
break
;
case
AV_CODEC_ID_OPUS
:
if
(
size
>
s
->
max_payload_size
)
{
av_log
(
s1
,
AV_LOG_ERROR
,
"Packet size %d too large for max RTP payload size %d
\n
"
,
size
,
s
->
max_payload_size
);
return
AVERROR
(
EINVAL
);
}
/* Intentional fallthrough */
default:
/* better than nothing : send the codec raw data */
rtp_send_raw
(
s1
,
pkt
->
data
,
size
);
...
...
libavformat/sdp.c
View file @
c136a813
...
...
@@ -576,6 +576,10 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c,
av_strlcatf
(
buff
,
size
,
"a=rtpmap:%d speex/%d
\r\n
"
,
payload_type
,
c
->
sample_rate
);
break
;
case
AV_CODEC_ID_OPUS
:
av_strlcatf
(
buff
,
size
,
"a=rtpmap:%d opus/48000
\r\n
"
,
payload_type
);
break
;
default:
/* Nothing special to do here... */
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment