[Libav-user] Determine if input protocol is RTSP or file

Lukas Bommes Lukas.Bommes at gmx.de
Wed Jul 10 10:18:16 EEST 2019


Thanks for the hint with AVFormatContext.iformat.name. That worked well!

If someone has a similar issue, here is a function to parse the list of
names and check if "rtsp" is part of it.

###########

bool check_format_rtsp(const char *format_names) {

         char str[strlen(format_names) + 1];
         strcpy(str, format_names);

         char *format_name;
         char *buffer = str;

         while ((format_name = strtok_r(buffer, ",", &buffer))) {

             if (strcmp(format_name, "rtsp") == 0)
                 return true;
         }

         return false;

}

###########

Best regards,

Lukas


On 05.07.2019 21:12, Philippe Gorley wrote:
> On 2019-07-05 2:23 a.m., lukas wrote:
>> Dear libavusers,
>>
>> I patched some files of libavformat and libavcodec to include timestamps
>> from RTPDemuxContext in the AVPacket (I did it similar to [1]). This is
>> for the purpose of synchronizing multiple streams on the receiver side
>> and works fine. Of course, it only works when the stream protocol is
>> RTSP or RTP, not if the input is a file or another protocol that does
>> not use RTPDemuxContext.
>>
>> Is there any value in AVFormatContext (or similar) which indicates of
>> what protocol an opened stream is? Or do I have to manually parse the
>> url to determine, if a RTSP source or a file is opened?
>
> AVFormatContext.iformat.name should be "rtp" or "rtsp".
>
>>
>> Also, it would be helpful if the RTP and NTP timestamps from
>> RTPDemuxContext would be exposed in the public API, so that no patch is
>> needed. I found some solutions [2] which use the internal header files,
>> but finally decided to just patch the public API since I could not get
>> it compiled with the internal headers. Would it make sense to include
>> this modification? Or does it brake compatibility with other protocols?
>
> I'd suggest having a chat with the devs over on #ffmpeg-devel
> (freenode). They're better placed to give you an answer.
>
>>
>> Kind regards,
>>
>> Lukas Bommes
>>
>> [1] https://github.com/bytedeco/javacpp-presets/issues/374
>>
>> [2]
>> https://stackoverflow.com/questions/20094998/retrieving-timestamp-in-rtp-rtsp
>>
>>
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/libav-user
>>
>> To unsubscribe, visit link above, or email
>> libav-user-request at ffmpeg.org with subject "unsubscribe".
>
> Cheers,
>


More information about the Libav-user mailing list