to resolve the Prevent issues 35/42935/1
authorHyunil Park <hyunil46.park@samsung.com>
Mon, 6 Jul 2015 06:40:36 +0000 (15:40 +0900)
committerHyunil Park <hyunil46.park@samsung.com>
Mon, 6 Jul 2015 06:40:36 +0000 (15:40 +0900)
Change-Id: I60ca6ee40fbd11ec1b9d40a84c57295064976a96
Signed-off-by: Hyunil Park <hyunil46.park@samsung.com>
src/mm_player_es.c
src/mm_player_priv.c

index 4e013b1..21efc6c 100755 (executable)
@@ -340,11 +340,12 @@ int
 _mmplayer_submit_packet (MMHandleType hplayer, media_packet_h packet)
 {
   int ret = MM_ERROR_NONE;
-  GstBuffer *_buffer;
+  GstBuffer *_buffer = NULL;
   mm_player_t *player = (mm_player_t *) hplayer;
   guint8 *buf = NULL;
   MMPlayerTrackType streamtype = MM_PLAYER_TRACK_TYPE_AUDIO;
   media_format_h fmt = NULL;
+  bool flag = FALSE;
 
   return_val_if_fail (packet, MM_ERROR_INVALID_ARGUMENT);
   return_val_if_fail ( player &&
@@ -353,6 +354,19 @@ _mmplayer_submit_packet (MMHandleType hplayer, media_packet_h packet)
     player->pipeline->mainbin[MMPLAYER_M_SRC].gst,
     MM_ERROR_PLAYER_INTERNAL );
 
+  /* get stream type if audio or video */
+  media_packet_is_audio (packet, &flag);
+  if (flag) {
+       streamtype = MM_PLAYER_TRACK_TYPE_AUDIO;
+  } else {
+       media_packet_is_video (packet, &flag);
+
+       if (flag)
+         streamtype = MM_PLAYER_TRACK_TYPE_VIDEO;
+       else
+         streamtype = MM_PLAYER_TRACK_TYPE_TEXT;
+  }
+
   /* get data */
   media_packet_get_buffer_data_ptr (packet, (void **) &buf);
 
@@ -360,12 +374,16 @@ _mmplayer_submit_packet (MMHandleType hplayer, media_packet_h packet)
     GstMapInfo buff_info = GST_MAP_INFO_INIT;
     uint64_t size = 0;
     uint64_t pts = 0;
-    bool flag = FALSE;
 
     /* get size */
     media_packet_get_buffer_size (packet, &size);
 
     _buffer = gst_buffer_new_and_alloc (size);
+    if (!_buffer) {
+        debug_error("failed to allocate memory for push buffer\n");
+        return MM_ERROR_PLAYER_NO_FREE_SPACE;
+    }
+
     if (gst_buffer_map (_buffer, &buff_info, GST_MAP_READWRITE)) {
 
       memcpy (buff_info.data, buf, size);
@@ -378,19 +396,6 @@ _mmplayer_submit_packet (MMHandleType hplayer, media_packet_h packet)
     media_packet_get_pts (packet, &pts);
     GST_BUFFER_PTS (_buffer) = (GstClockTime) (pts * 1000000);
 
-    /* get stream type if audio or video */
-    media_packet_is_audio (packet, &flag);
-    if (flag) {
-      streamtype = MM_PLAYER_TRACK_TYPE_AUDIO;
-    } else {
-      media_packet_is_video (packet, &flag);
-
-      if (flag)
-        streamtype = MM_PLAYER_TRACK_TYPE_VIDEO;
-      else
-        streamtype = MM_PLAYER_TRACK_TYPE_TEXT;
-    }
-
     if (streamtype == MM_PLAYER_TRACK_TYPE_AUDIO) {
 #if 0                           // TO CHECK : has gone (set to pad)
       if (GST_CAPS_IS_SIMPLE (player->a_stream_caps))
index be903d7..64aeb9d 100755 (executable)
@@ -6079,9 +6079,12 @@ __mmplayer_gst_create_video_pipeline(mm_player_t* player, GstCaps* caps, MMDispl
        {
                GstPad *sink_pad = NULL;
                sink_pad = gst_element_get_static_pad(videobin[MMPLAYER_V_SINK].gst, "sink");
-               MMPLAYER_SIGNAL_CONNECT (player, sink_pad, MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
+               if (sink_pad)
+               {
+                       MMPLAYER_SIGNAL_CONNECT (player, sink_pad, MM_PLAYER_SIGNAL_TYPE_VIDEOBIN,
                                        "notify::caps", G_CALLBACK(__mmplayer_gst_caps_notify_cb), player);
-               gst_object_unref (GST_OBJECT(sink_pad));
+                       gst_object_unref (GST_OBJECT(sink_pad));
+               }
        }
 
        /* store it as it's sink element */
@@ -11488,6 +11491,7 @@ __mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstC
        MMPlayerGstElement* mainbin = NULL;
        GstElement* decodebin2 = NULL;
        GstElement* queue2 = NULL;
+       GstElement* id3demux = NULL;
        GstPad* sinkpad = NULL;
        GstPad* qsrcpad= NULL;
        gchar *caps_str = NULL;
@@ -11668,6 +11672,22 @@ ERROR:
                queue2 = NULL;
        }
 
+       if (id3demux)
+       {
+               /* NOTE : Trying to dispose element id3demux, but it is in READY instead of the NULL state.
+                * You need to explicitly set elements to the NULL state before
+                * dropping the final reference, to allow them to clean up.
+                */
+               gst_element_set_state(id3demux, GST_STATE_NULL);
+
+               /* And, it still has a parent "player".
+                * You need to let the parent manage the object instead of unreffing the object directly.
+                */
+               gst_bin_remove (GST_BIN(mainbin[MMPLAYER_M_PIPE].gst), id3demux);
+               gst_object_unref (id3demux);
+               id3demux = NULL;
+       }
+
        if (decodebin2)
        {
                /* NOTE : Trying to dispose element queue0, but it is in READY instead of the NULL state.
@@ -11858,11 +11878,11 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) //
                        if( temp1->direction != GST_PAD_SINK
                                || temp1->presence != GST_PAD_ALWAYS)
                                continue;
-#if 0 //should check
+
                        if ( GST_IS_CAPS( &temp1->static_caps.caps) )
                        {
                                /* using existing caps */
-                               static_caps = gst_caps_ref( &temp1->static_caps.caps );
+                               static_caps = gst_caps_ref(temp1->static_caps.caps );
                        }
                        else
                        {
@@ -11870,8 +11890,7 @@ __mmplayer_try_to_plug(mm_player_t* player, GstPad *pad, const GstCaps *caps) //
                                static_caps = gst_caps_from_string ( temp1->static_caps.string );
                        }
 
-                       res = gst_caps_intersect(caps, static_caps);
-#endif
+                       res = gst_caps_intersect((GstCaps*)caps, static_caps);
                        gst_caps_unref( static_caps );
                        static_caps = NULL;