Improved management of failed sources

Clone is failed if its origin is failed, handle MediaPlayer visitor and error message when fail, get SourceList of non-failed sources of a list.
This commit is contained in:
Bruno Herbelin
2023-01-29 10:50:00 +01:00
parent e69ac7ca28
commit 0051533ac8
7 changed files with 81 additions and 60 deletions

View File

@@ -157,72 +157,74 @@ MediaInfo MediaPlayer::UriDiscoverer(const std::string &uri)
}
break;
default:
case GST_DISCOVERER_OK:
break;
}
// get videos in information found
GList *streams = gst_discoverer_info_get_video_streams(info);
if ( g_list_length(streams) > 0) {
GList *tmp;
for (tmp = streams; tmp && !video_stream_info.valid; tmp = tmp->next ) {
GstDiscovererStreamInfo *tmpinf = (GstDiscovererStreamInfo *) tmp->data;
if ( GST_IS_DISCOVERER_VIDEO_INFO(tmpinf) )
{
// found a video / image stream : fill-in information
GstDiscovererVideoInfo* vinfo = GST_DISCOVERER_VIDEO_INFO(tmpinf);
video_stream_info.width = gst_discoverer_video_info_get_width(vinfo);
video_stream_info.height = gst_discoverer_video_info_get_height(vinfo);
guint parn = gst_discoverer_video_info_get_par_num(vinfo);
guint pard = gst_discoverer_video_info_get_par_denom(vinfo);
video_stream_info.par_width = (video_stream_info.width * parn) / pard;
video_stream_info.interlaced = gst_discoverer_video_info_is_interlaced(vinfo);
video_stream_info.bitrate = gst_discoverer_video_info_get_bitrate(vinfo);
video_stream_info.isimage = gst_discoverer_video_info_is_image(vinfo);
// if its a video, set duration, framerate, etc.
if ( !video_stream_info.isimage ) {
video_stream_info.end = gst_discoverer_info_get_duration (info) ;
video_stream_info.seekable = gst_discoverer_info_get_seekable (info);
video_stream_info.framerate_n = gst_discoverer_video_info_get_framerate_num(vinfo);
video_stream_info.framerate_d = gst_discoverer_video_info_get_framerate_denom(vinfo);
if (video_stream_info.framerate_n == 0 || video_stream_info.framerate_d == 0) {
Log::Info("'%s': No framerate indicated in the file; using default 30fps", uri.c_str());
video_stream_info.framerate_n = 30;
video_stream_info.framerate_d = 1;
if ( result == GST_DISCOVERER_OK ) {
// get videos in information found
GList *streams = gst_discoverer_info_get_video_streams(info);
if ( g_list_length(streams) > 0) {
GList *tmp;
for (tmp = streams; tmp && !video_stream_info.valid; tmp = tmp->next ) {
GstDiscovererStreamInfo *tmpinf = (GstDiscovererStreamInfo *) tmp->data;
if ( GST_IS_DISCOVERER_VIDEO_INFO(tmpinf) )
{
// found a video / image stream : fill-in information
GstDiscovererVideoInfo* vinfo = GST_DISCOVERER_VIDEO_INFO(tmpinf);
video_stream_info.width = gst_discoverer_video_info_get_width(vinfo);
video_stream_info.height = gst_discoverer_video_info_get_height(vinfo);
guint parn = gst_discoverer_video_info_get_par_num(vinfo);
guint pard = gst_discoverer_video_info_get_par_denom(vinfo);
video_stream_info.par_width = (video_stream_info.width * parn) / pard;
video_stream_info.interlaced = gst_discoverer_video_info_is_interlaced(vinfo);
video_stream_info.bitrate = gst_discoverer_video_info_get_bitrate(vinfo);
video_stream_info.isimage = gst_discoverer_video_info_is_image(vinfo);
// if its a video, set duration, framerate, etc.
if ( !video_stream_info.isimage ) {
video_stream_info.end = gst_discoverer_info_get_duration (info) ;
video_stream_info.seekable = gst_discoverer_info_get_seekable (info);
video_stream_info.framerate_n = gst_discoverer_video_info_get_framerate_num(vinfo);
video_stream_info.framerate_d = gst_discoverer_video_info_get_framerate_denom(vinfo);
if (video_stream_info.framerate_n == 0 || video_stream_info.framerate_d == 0) {
Log::Info("'%s': No framerate indicated in the file; using default 30fps", uri.c_str());
video_stream_info.framerate_n = 30;
video_stream_info.framerate_d = 1;
}
video_stream_info.dt = ( (GST_SECOND * static_cast<guint64>(video_stream_info.framerate_d)) / (static_cast<guint64>(video_stream_info.framerate_n)) );
// confirm (or infirm) that its not a single frame
if ( video_stream_info.end < video_stream_info.dt * 2)
video_stream_info.isimage = true;
}
video_stream_info.dt = ( (GST_SECOND * static_cast<guint64>(video_stream_info.framerate_d)) / (static_cast<guint64>(video_stream_info.framerate_n)) );
// confirm (or infirm) that its not a single frame
if ( video_stream_info.end < video_stream_info.dt * 2)
video_stream_info.isimage = true;
// try to fill-in the codec information
GstCaps *caps = gst_discoverer_stream_info_get_caps (tmpinf);
if (caps) {
gchar *codecstring = gst_pb_utils_get_codec_description(caps);
video_stream_info.codec_name = std::string( codecstring );
g_free(codecstring);
gst_caps_unref (caps);
}
const GstTagList *tags = gst_discoverer_stream_info_get_tags(tmpinf);
if ( tags ) {
gchar *container = NULL;
if ( gst_tag_list_get_string (tags, GST_TAG_CONTAINER_FORMAT, &container) )
video_stream_info.codec_name += ", " + std::string(container);
if (container)
g_free(container);
}
// exit loop
// inform that it succeeded
video_stream_info.valid = true;
}
// try to fill-in the codec information
GstCaps *caps = gst_discoverer_stream_info_get_caps (tmpinf);
if (caps) {
gchar *codecstring = gst_pb_utils_get_codec_description(caps);
video_stream_info.codec_name = std::string( codecstring );
g_free(codecstring);
gst_caps_unref (caps);
}
const GstTagList *tags = gst_discoverer_stream_info_get_tags(tmpinf);
if ( tags ) {
gchar *container = NULL;
if ( gst_tag_list_get_string (tags, GST_TAG_CONTAINER_FORMAT, &container) )
video_stream_info.codec_name += ", " + std::string(container);
if (container)
g_free(container);
}
// exit loop
// inform that it succeeded
video_stream_info.valid = true;
}
if (!video_stream_info.valid)
Log::Warning("'%s': Invalid video stream", uri.c_str());
}
else
Log::Warning("'%s': No video stream", uri.c_str());
if (!video_stream_info.valid)
Log::Warning("'%s': Invalid video stream", uri.c_str());
gst_discoverer_stream_info_list_free(streams);
}
else
Log::Warning("'%s': No supported video stream", uri.c_str());
gst_discoverer_stream_info_list_free(streams);
if (info)
gst_discoverer_info_unref (info);