diff mbox series

[FFmpeg-devel,3/3] avformat/flv: add support for opus streams

Message ID 20210701141528.776-3-jamrial@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/3] avformat/flv: add support for h265 streams
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

James Almer July 1, 2021, 2:15 p.m. UTC
From: Matthieu Patou <mpatou@fb.com>

Suggested-by: ffmpeg@fb.com
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavformat/flv.h    |  6 ++++--
 libavformat/flvdec.c | 11 +++++++++--
 2 files changed, 13 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/flv.h b/libavformat/flv.h
index 29bb36f7f6..6f3cad04e1 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -97,8 +97,10 @@  enum {
     FLV_CODECID_NELLYMOSER           = 6 << FLV_AUDIO_CODECID_OFFSET,
     FLV_CODECID_PCM_ALAW             = 7 << FLV_AUDIO_CODECID_OFFSET,
     FLV_CODECID_PCM_MULAW            = 8 << FLV_AUDIO_CODECID_OFFSET,
-    FLV_CODECID_AAC                  = 10<< FLV_AUDIO_CODECID_OFFSET,
-    FLV_CODECID_SPEEX                = 11<< FLV_AUDIO_CODECID_OFFSET,
+    FLV_CODECID_OPUS                 = 9 << FLV_AUDIO_CODECID_OFFSET,
+    FLV_CODECID_AAC                  = 10 << FLV_AUDIO_CODECID_OFFSET,
+    FLV_CODECID_SPEEX                = 11 << FLV_AUDIO_CODECID_OFFSET,
+
 };
 
 enum {
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index dafedb4770..48ef220a22 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -236,6 +236,8 @@  static int flv_same_audio_codec(AVCodecParameters *apar, int flags)
     case FLV_CODECID_PCM_ALAW:
         return apar->sample_rate == 8000 &&
                apar->codec_id    == AV_CODEC_ID_PCM_ALAW;
+    case FLV_CODECID_OPUS:
+        return apar->codec_id == AV_CODEC_ID_OPUS;
     default:
         return apar->codec_tag == (flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
     }
@@ -294,6 +296,9 @@  static void flv_set_audio_codec(AVFormatContext *s, AVStream *astream,
         apar->sample_rate = 8000;
         apar->codec_id    = AV_CODEC_ID_PCM_ALAW;
         break;
+    case FLV_CODECID_OPUS:
+        apar->codec_id    = AV_CODEC_ID_OPUS;
+        break;
     default:
         avpriv_request_sample(s, "Audio codec (%x)",
                flv_codecid >> FLV_AUDIO_CODECID_OFFSET);
@@ -1261,7 +1266,8 @@  retry_duration:
         st->codecpar->codec_id == AV_CODEC_ID_H265 ||
         st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
         st->codecpar->codec_id == AV_CODEC_ID_VP8 ||
-        st->codecpar->codec_id == AV_CODEC_ID_VP9) {
+        st->codecpar->codec_id == AV_CODEC_ID_VP9 ||
+        st->codecpar->codec_id == AV_CODEC_ID_OPUS) {
         int type = avio_r8(s->pb);
         size--;
 
@@ -1289,7 +1295,8 @@  retry_duration:
         }
         if (type == 0 && (!st->codecpar->extradata || st->codecpar->codec_id == AV_CODEC_ID_AAC ||
             st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_H265 ||
-            st->codecpar->codec_id == AV_CODEC_ID_VP8 || st->codecpar->codec_id == AV_CODEC_ID_VP9)) {
+            st->codecpar->codec_id == AV_CODEC_ID_VP8 || st->codecpar->codec_id == AV_CODEC_ID_VP9 ||
+            st->codecpar->codec_id == AV_CODEC_ID_OPUS)) {
             AVDictionaryEntry *t;
 
             if (st->codecpar->extradata) {