diff mbox series

[FFmpeg-devel] avformat/flvdec: RtmpSampleAccess no longer breaks stream detection

Message ID 20200817092508.97973-1-p.vanderspek@bluebillywig.com
State Superseded
Headers show
Series [FFmpeg-devel] avformat/flvdec: RtmpSampleAccess no longer breaks stream detection | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Peter van der Spek Aug. 17, 2020, 9:25 a.m. UTC
Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
stream that contains a |RtmpSampleAccess AMF object prior to the
onMetaData AMF object. In the debug log it would show "[flv] Unknown
type |RtmpSampleAccess".

With this change the RTMP streams are correctly detected when there
is a |RtmpSampleAccess object prior to the onMetaData object.

Signed-off-by: Peter van der Spek <p.vanderspek@bluebillywig.com>
---
 libavformat/flvdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Aug. 18, 2020, 12:46 p.m. UTC | #1
On Mon, Aug 17, 2020 at 11:25:08AM +0200, Peter van der Spek wrote:
> Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
> stream that contains a |RtmpSampleAccess AMF object prior to the
> onMetaData AMF object. In the debug log it would show "[flv] Unknown
> type |RtmpSampleAccess".
> 
> With this change the RTMP streams are correctly detected when there
> is a |RtmpSampleAccess object prior to the onMetaData object.
> 
> Signed-off-by: Peter van der Spek <p.vanderspek@bluebillywig.com>
> ---
>  libavformat/flvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Do you have a testcase?
Is this documented somewhere?

thx

[...]
Peter van der Spek Aug. 18, 2020, 2:21 p.m. UTC | #2
It took me some time to figure out where this |RtmpSampleAccess packet came from. It turns out that this is an undocumented AMF packet that is used to transfer the state of the documented Client.audioSampleAccess and Client.videoSampleAccess state to the client.

This post gave me some clues: https://nicolas.brousse.info/blog/flash-how-to-fix-the-security-sandbox-violation-bitmapdata-draw/

These sampleAccess states are used to allow a (Flash) client to access the raw video and audio data. The states are pushed by the server as a IRtmpSampleAccess packet.

Adobe FMS, Wowza, Red5, etc… all support this mechanism.

I’m able to reproduce this issue with RTMP streams pulled from a Nginx-RTMP server (https://github.com/arut/nginx-rtmp-module).

Client.audioSampleAccess and Client.videoSampleAccess are documented here:
https://helpx.adobe.com/adobe-media-server/ssaslr/client-class.html#client_audiosampleaccess
https://helpx.adobe.com/adobe-media-server/ssaslr/client-class.html#client_videosampleaccess

Best,
Peter
On 18 Aug 2020, 14:46 +0200, Michael Niedermayer <michael@niedermayer.cc>, wrote:
>
> Do you have a testcase?
> Is this documented somewhere?
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> In a rich man's house there is no place to spit but his face.
> -- Diogenes of Sinope
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Andreas Rheinhardt Aug. 18, 2020, 4:04 p.m. UTC | #3
Peter van der Spek:
> Since release 4.2, FFmpeg fails to detect the correct streams in an RTMP
> stream that contains a |RtmpSampleAccess AMF object prior to the
> onMetaData AMF object. In the debug log it would show "[flv] Unknown
> type |RtmpSampleAccess".
> 
> With this change the RTMP streams are correctly detected when there
> is a |RtmpSampleAccess object prior to the onMetaData object.
> 
> Signed-off-by: Peter van der Spek <p.vanderspek@bluebillywig.com>
> ---
>  libavformat/flvdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
> index 0862273..d480d0b 100644
> --- a/libavformat/flvdec.c
> +++ b/libavformat/flvdec.c
> @@ -715,7 +715,7 @@ static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
>      if (!strcmp(buffer, "onCaptionInfo"))
>          return TYPE_ONCAPTIONINFO;
>  
> -    if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint")) {
> +    if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && strcmp(buffer, "|RtmpSampleAccess")) {
>          av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
>          return TYPE_UNKNOWN;
>      }
> 
Which commit broke it? (That should be included in the commit message.)

- Andreas
diff mbox series

Patch

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 0862273..d480d0b 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -715,7 +715,7 @@  static int flv_read_metabody(AVFormatContext *s, int64_t next_pos)
     if (!strcmp(buffer, "onCaptionInfo"))
         return TYPE_ONCAPTIONINFO;
 
-    if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint")) {
+    if (strcmp(buffer, "onMetaData") && strcmp(buffer, "onCuePoint") && strcmp(buffer, "|RtmpSampleAccess")) {
         av_log(s, AV_LOG_DEBUG, "Unknown type %s\n", buffer);
         return TYPE_UNKNOWN;
     }