]> git.sesse.net Git - vlc/blobdiff - modules/access/live555.cpp
mp4 mux: encode video orientation
[vlc] / modules / access / live555.cpp
index 824cdf2198ae7daf8488e6c32a12abfeddc7ac48..163ae2dd52c2fea9186e3474858d0c06bfcdebba 100644 (file)
@@ -685,6 +685,8 @@ static int SessionsSetup( demux_t *p_demux )
     unsigned int   i_receive_buffer = 0;
     int            i_frame_buffer = DEFAULT_FRAME_BUFFER_SIZE;
     unsigned const thresh = 200000; /* RTP reorder threshold .2 second (default .1) */
+    const char     *p_sess_lang = NULL;
+    const char     *p_lang;
 
     b_rtsp_tcp    = var_CreateGetBool( p_demux, "rtsp-tcp" ) ||
                     var_GetBool( p_demux, "rtsp-http" );
@@ -699,6 +701,20 @@ static int SessionsSetup( demux_t *p_demux )
         return VLC_EGENERIC;
     }
 
+    if( strcmp( p_sys->p_sdp, "m=" ) != 0 )
+    {
+        const char *p_sess_attr_end;
+
+        p_sess_attr_end = strstr( p_sys->p_sdp, "\nm=" );
+        if( !p_sess_attr_end )
+            p_sess_attr_end = strstr( p_sys->p_sdp, "\rm=" );
+
+        p_sess_lang = p_sess_attr_end ? strstr( p_sys->p_sdp, "a=lang:" ) : NULL;
+        if( p_sess_lang &&
+            p_sess_lang - p_sys->p_sdp > p_sess_attr_end - p_sys->p_sdp )
+            p_sess_lang = NULL;
+    }
+
     /* Initialise each media subsession */
     iter = new MediaSubsessionIterator( *p_sys->ms );
     while( ( sub = iter->next() ) != NULL )
@@ -1017,6 +1033,40 @@ static int SessionsSetup( demux_t *p_demux )
                         delete[] p_extra;
                     }
                 }
+#if LIVEMEDIA_LIBRARY_VERSION_INT >= 1393372800 // 2014.02.26
+                else if( !strcmp( sub->codecName(), "H265" ) )
+                {
+                   unsigned int i_extra1 = 0, i_extra2 = 0, i_extra3 = 0, i_extraTot;
+                    uint8_t      *p_extra1 = NULL, *p_extra2 = NULL, *p_extra3 = NULL;
+
+                    tk->fmt.i_codec = VLC_CODEC_HEVC;
+                    tk->fmt.b_packetized = false;
+
+                    p_extra1 = parseH264ConfigStr( sub->fmtp_spropvps(), i_extra1 );
+                    p_extra2 = parseH264ConfigStr( sub->fmtp_spropsps(), i_extra2 );
+                    p_extra3 = parseH264ConfigStr( sub->fmtp_sproppps(), i_extra3 );
+                   i_extraTot = i_extra1 + i_extra2 + i_extra3;
+                   if( i_extraTot > 0 )
+                    {
+                        tk->fmt.i_extra = i_extraTot;
+                        tk->fmt.p_extra = xmalloc( i_extraTot );
+                       if( p_extra1 )
+                       {
+                            memcpy( tk->fmt.p_extra, p_extra1, i_extra1 );
+                       }
+                       if( p_extra2 )
+                       {
+                         memcpy( ((char*)tk->fmt.p_extra)+i_extra1, p_extra2, i_extra2 );
+                       }
+                       if( p_extra3 )
+                       {
+                         memcpy( ((char*)tk->fmt.p_extra)+i_extra1+i_extra2, p_extra3, i_extra3 );
+                       }
+
+                        delete[] p_extra1; delete[] p_extra2; delete[] p_extra3;
+                    }
+                }
+#endif
                 else if( !strcmp( sub->codecName(), "JPEG" ) )
                 {
                     tk->fmt.i_codec = VLC_CODEC_MJPG;
@@ -1075,6 +1125,20 @@ static int SessionsSetup( demux_t *p_demux )
                 {
                     tk->fmt.i_codec = VLC_CODEC_VP8;
                 }
+                else if( !strcmp( sub->codecName(), "THEORA" ) )
+                {
+                    tk->fmt.i_codec = VLC_CODEC_THEORA;
+                    unsigned int i_extra;
+                    unsigned char *p_extra;
+                    if( ( p_extra=parseVorbisConfigStr( sub->fmtp_config(),
+                                                        i_extra ) ) )
+                    {
+                        tk->fmt.i_extra = i_extra;
+                        tk->fmt.p_extra = p_extra;
+                    }
+                    else
+                        msg_Warn( p_demux,"Missing or unsupported theora header." );
+                }
             }
             else if( !strcmp( sub->mediumName(), "text" ) )
             {
@@ -1086,6 +1150,19 @@ static int SessionsSetup( demux_t *p_demux )
                 }
             }
 
+            /* Try and parse a=lang: attribute */
+            p_lang = strstr( sub->savedSDPLines(), "a=lang:" );
+            if( !p_lang )
+                p_lang = p_sess_lang;
+
+            if( p_lang )
+            {
+                unsigned i_lang_len;
+                p_lang += 7;
+                i_lang_len = strcspn( p_lang, " \r\n" );
+                tk->fmt.psz_language = strndup( p_lang, i_lang_len );
+            }
+
             if( !tk->b_quicktime && !tk->b_muxed && !tk->b_asf )
             {
                 tk->p_es = es_out_Add( p_demux->out, &tk->fmt );
@@ -1904,10 +1981,12 @@ static void StreamRead( void *p_private, unsigned int i_size,
         if( tk->sub->rtpSource()->curPacketMarkerBit() )
             p_block->i_flags |= BLOCK_FLAG_END_OF_FRAME;
     }
-    else if( tk->fmt.i_codec == VLC_CODEC_H264 )
+    else if( tk->fmt.i_codec == VLC_CODEC_H264 || tk->fmt.i_codec == VLC_CODEC_HEVC )
     {
-        if( (tk->p_buffer[0] & 0x1f) >= 24 )
+        if( tk->fmt.i_codec == VLC_CODEC_H264 && (tk->p_buffer[0] & 0x1f) >= 24 )
             msg_Warn( p_demux, "unsupported NAL type for H264" );
+        else if( tk->fmt.i_codec == VLC_CODEC_HEVC && ((tk->p_buffer[0] & 0x7e)>>1) >= 48 )
+            msg_Warn( p_demux, "unsupported NAL type for H265" );
 
         /* Normal NAL type */
         p_block = block_Alloc( i_size + 4 );