2017-05-08 41 views
1

我覺得我錯過了一些明顯的東西,所以我提前致歉。Gstreamer gst_event_new_seek啓動和停止位置

我正在通過GStreamer Basic tutorial 13: Playback speed。雖然我覺得我抓住它,我對下面的句子(我的粗體)在send_seek_event代碼的解釋困惑:

事件與gst_event_new_seek創建尋找()。它的參數 ,基本上是新的利率,新的開始位置和新的止損位置。無論播放方向如何,的起始位置 必須小於停止位置,因此兩個播放方向 的處理方式不同。

然而,(在相同的教程),用於創建,這將改變回放速率的事件的代碼:

/* Obtain the current position, needed for the seek event */ 
    if (!gst_element_query_position (data->pipeline, GST_FORMAT_TIME, &position)) { 
    g_printerr ("Unable to retrieve current position.\n"); 
    return; 
    } 

    /* Create the seek event */ 
    if (data->rate > 0) { 
    seek_event = gst_event_new_seek (data->rate, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, 
     GST_SEEK_TYPE_SET, position, GST_SEEK_TYPE_NONE, 0); 
    } else { 
    seek_event = gst_event_new_seek (data->rate, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE, 
     GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_SET, position); 
    } 

在代碼:

  • 用於速率> 0(播放向前),start_position是位置(> 0),stop_position是0
  • 對於費率< 0(向後播放),start_position是0,stop_position是位置(> 0)

這是教程中的錯字嗎?我錯過了真正明顯的東西嗎?

回答

0

當速率< 0時,回放從stop_position開始並轉到start_position。 因此,起始位置小於停止位置。

+0

是的,在這種情況下,start_position = 0 0.當速率> 0時,start_position = position和stop_position = 0。由於位置大於0,它似乎不符合start_position airos