Choose caps to make a decoder element 56/314956/4 accepted/tizen/unified/20240727.112744 accepted/tizen/unified/dev/20240730.010459 accepted/tizen/unified/toolchain/20240812.133249 accepted/tizen/unified/x/20240729.014253 accepted/tizen/unified/x/asan/20240813.231723
authorGilbok Lee <gilbok.lee@samsung.com>
Tue, 23 Jul 2024 08:55:18 +0000 (17:55 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Thu, 25 Jul 2024 06:28:41 +0000 (15:28 +0900)
-finding the wrong decoder because there are several src pad templates
 in some parsers(mpeg4videoparser/ac3parser)

[Version] 0.0.57
[Issue Type] Fix bugs

Change-Id: Ia42c7c37cbdd6e0b3a1a6d4882ef7a3067637638

packaging/libtrackrenderer.spec
src/trackrenderer.cpp

index d87f3fa..fa49db2 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libtrackrenderer
 Summary:    new multimedia streaming player trackrenderer
-Version:    0.0.56
+Version:    0.0.57
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 08cdb3a..384c4f6 100644 (file)
@@ -1023,6 +1023,31 @@ void TrackRenderer::GstCapsNotifyCb_(GstPad* pad, GParamSpec* unused, gpointer u
   TRACKRENDERER_LEAVE;
 }
 
+static GstCaps* ChooseDecoderCaps(GstCaps* inputCaps, GstCaps* parseCaps)
+{
+  auto GetMimeFunc = [](GstCaps* caps) -> std::string {
+    if (!caps) return {};
+    GstStructure* s = gst_caps_get_structure(caps, 0);
+    if (!s) return {};
+
+    return gst_structure_get_name(s);
+  };
+
+  auto inputMime = GetMimeFunc(inputCaps);
+  if (inputMime.empty()) {
+    TRACKRENDERER_ERROR("Invalid inputCaps, return null");
+    return nullptr;
+  }
+
+  auto parseMime = GetMimeFunc(parseCaps);
+  if (parseMime.empty()) {
+    TRACKRENDERER_ERROR("Invalid parseCaps, return inputCaps");
+    return inputCaps;
+  }
+
+  return (inputMime == parseMime) ? parseCaps : inputCaps;
+}
+
 bool TrackRenderer::CreateVideoPipeline_(const Track* track) {
   TRACKRENDERER_ENTER;
 
@@ -1045,7 +1070,7 @@ bool TrackRenderer::CreateVideoPipeline_(const Track* track) {
   auto parse_caps =
       gstguard::make_guard(pipeline_->GetSrcPadCaps(Elements::kParseVideo));
 
-  if (!CreateDecoder_(track, parse_caps ? static_cast<GstCaps*>(parse_caps.get()) : caps.GetCaps_())) {
+  if (!CreateDecoder_(track, ChooseDecoderCaps(caps.GetCaps_(), static_cast<GstCaps*>(parse_caps.get())))) {
     TRACKRENDERER_ERROR("Failed to make video decoder");
     pipeline_->ElementRemove(Elements::kAppSrcVideo);
     pipeline_->ElementRemove(Elements::kParseVideo);
@@ -1138,7 +1163,7 @@ bool TrackRenderer::CreateAudioPipeline_(const Track* track) {
   auto parse_caps =
       gstguard::make_guard(pipeline_->GetSrcPadCaps(Elements::kParseAudio));
 
-  if (!CreateDecoder_(track, parse_caps ? static_cast<GstCaps*>(parse_caps.get()) : caps.GetCaps_())) {
+  if (!CreateDecoder_(track, ChooseDecoderCaps(caps.GetCaps_(), static_cast<GstCaps*>(parse_caps.get())))) {
     TRACKRENDERER_ERROR("Failed to make audio decoder");
     const ErrorType err = ErrorType::kNotSupportedAudioCodec;
     eventlistener_->OnError(err);