[0.6.208] Clean up _mmplayer_do_video_capture() function 14/217414/4
authorGilbok Lee <gilbok.lee@samsung.com>
Mon, 11 Nov 2019 08:34:44 +0000 (17:34 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Wed, 13 Nov 2019 02:07:13 +0000 (11:07 +0900)
Change-Id: I31e3b857d3605b3c362b76062eee81464e3c7990

packaging/libmm-player.spec
src/mm_player_capture.c

index 67e6699..1ec3577 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-player
 Summary:    Multimedia Framework Player Library
-Version:    0.6.207
+Version:    0.6.208
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index dd24c0d..45c638a 100644 (file)
@@ -139,40 +139,32 @@ _mmplayer_do_video_capture(MMHandleType hplayer)
 
        pad = gst_element_get_static_pad(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "sink");
 
-       if (player->state != MM_PLAYER_STATE_PLAYING) {
-               if (player->state == MM_PLAYER_STATE_PAUSED) {
-                       // get last buffer from video sink
-                       GstSample *sample = NULL;
-
-                       gst_element_get_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, NULL, NULL, 5 * GST_SECOND); //5 seconds
-                       g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-sample", &sample, NULL);
-
-                       if (sample) {
-                               GstBuffer *buf = NULL;
-                               buf = gst_sample_get_buffer(sample);
-                               if (buf) {
-                                       if (__mmplayer_get_video_frame_from_buffer(player, pad, buf) != MM_ERROR_NONE)
-                                               ret = MM_ERROR_PLAYER_INTERNAL;
-                               } else {
-                                       LOGW("failed to get video frame");
-                               }
-                               gst_sample_unref(sample);
+       if (player->state == MM_PLAYER_STATE_PLAYING) {
+               /* register probe */
+               player->video_capture_cb_probe_id = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER,
+                       __mmplayer_video_capture_probe, player, NULL);
+       } else if (player->state == MM_PLAYER_STATE_PAUSED) {
+               // get last buffer from video sink
+               GstSample *sample = NULL;
+
+               gst_element_get_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, NULL, NULL, 5 * GST_SECOND);
+               g_object_get(player->pipeline->videobin[MMPLAYER_V_SINK].gst, "last-sample", &sample, NULL);
+
+               if (sample) {
+                       GstBuffer *buf = gst_sample_get_buffer(sample);
+                       if (buf) {
+                               if (__mmplayer_get_video_frame_from_buffer(player, pad, buf) != MM_ERROR_NONE)
+                                       ret = MM_ERROR_PLAYER_INTERNAL;
+                       } else {
+                               LOGW("failed to get video frame");
                        }
-                       gst_object_unref(GST_OBJECT(pad));
-                       pad = NULL;
-                       return ret;
-               } else {
-                       LOGW("invalid state(%d) to capture", player->state);
-                       gst_object_unref(GST_OBJECT(pad));
-                       pad = NULL;
-                       return MM_ERROR_PLAYER_INVALID_STATE;
+                       gst_sample_unref(sample);
                }
+       } else {
+               LOGW("invalid state(%d) to capture", player->state);
+               ret = MM_ERROR_PLAYER_INVALID_STATE;
        }
 
-       /* register probe */
-       player->video_capture_cb_probe_id = gst_pad_add_probe(pad, GST_PAD_PROBE_TYPE_BUFFER,
-               __mmplayer_video_capture_probe, player, NULL);
-
        gst_object_unref(GST_OBJECT(pad));
        pad = NULL;