<div dir="ltr">I'm trying to create a media player that must supports the following features:<div><br></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>- Set Start and/or End position using TIME (timestamp);</div>
</div><div><div>- Set Start and/or End position using SAMPLE (for audio only);</div></div><div><div>- Set Start and/or End position using FRAME (for video only);</div></div><div><div><div>- Schedule a notification in a given TIME (timestamp);</div>
</div></div><div><div>- Schedule a notification in a given SAMPLE (for audio only);</div></div><div><div>- Schedule a notification in a given FRAME (for video only).</div></div></blockquote><div><div><br></div><div>It is easy to do things when the Start position where set using the same unit as the notification (both using TIME or SAMPLE or FRAME).</div>
<div>I managed to find a way to convert SAMPLE# to TIME and vice versa (the opposit).</div><div>Notice the END position doesn't really matter.</div><div><br></div><div>But when I try to set the Start position in FRAMEs and schedule a notification in TIME, it gets complicated, since I can't get the base time to schedule the notification.</div>
<div><br></div><div>I couldn't also make it work when I set the Start position in TIME and schedule a notification in FRAMEs. I can't find which is the frame corresponding to the Start position.</div><div><br></div>
<div>Does anyone know whether it is possible to do that?</div><div><br></div><div>Here is how I do things:</div><div><br></div><div>This is how I set the END position:<br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><div><div>gst_element_seek(pipeline, 1.0, endPosFormat, (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE), GST_SEEK_TYPE_NONE, 0, GST_SEEK_TYPE_SET, endPosition);</div></div></div></blockquote><div><div><br>
</div><div>This is how I set the START position:</div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div><div>gst_element_seek(pipeline, 1.0, startPosFormat, (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE), GST_SEEK_TYPE_SET, startPosition, GST_SEEK_TYPE_NONE, 0);</div>
</div></div></blockquote><div><div><br></div><div>startPostFormat and endPosFormat = FST_FORMAT_TIME for TIME.</div><div>startPostFormat and endPosFormat = GST_FORMAT_DEFAULT for SAMPLEs or FRAMEs.</div><div><br></div><div>
<br></div><div>1) When setting the Start position in TIME, I do this:</div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>- Set the start time using the seek instruction above.</div></div>
<div><div>- gst_element_set_start_time(pipeline, GST_CLOCK_TIME_NONE);</div></div><div><div>- gst_element_set_base_time(pipeline, startPosition);</div></div></blockquote><div><div><br></div><div>2) When setting the Start position in SAMPLEs, I do this:</div>
</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>- Set the start sample using the seek instruction above</div></div><div><div>- Convert the startPosition from SAMPLE to TIME using the RATE (got from the caps from the sink pad of the audio-sink element).</div>
</div><div><div><div>- gst_element_set_start_time(pipeline, GST_CLOCK_TIME_NONE);</div></div></div><div><div><div>- gst_element_set_base_time(pipeline, startPosition);</div></div></div></blockquote><div><div><br></div><div>
3) When setting the Start position in FRAMEs, I do this:</div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>- Set the start frame using the seek instruction above.</div></div><div><div>
- I can't find a corresponding TIME for this FRAME, since I can't find a FRAME RATE nor can guarantee it would be constant. Is it possible?</div></div></blockquote><div><div><br></div><div>4) When scheduling a TIME notification, I do this:</div>
</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div><div>- GstClock *clock = gst_pipeline_get_clock(GST_PIPELINE(pipeline));</div></div><div><div>- GstClockID *clockId = gst_clock_new_single_shot_id(clock, timeInNanoSecs);</div>
</div><div>- gst_clock_id_wait_async(clockId, MyCallback, NULL);</div></blockquote><div><div><br></div><div>5) When scheduling a SAMPLE notification, I do this:</div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">
<div><div>- Convert SAMPLE to TIME using the same procedure described in 2.</div></div><div><div>- Schedule the notification using the same procedure described in 4.</div></div></blockquote><div><div><br></div><div>6) When scheduling a FRAME notification, I do this:</div>
</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>- Create a pad probe in the sink pad of the videosink element, using gst_pad_add_buffer_probe.</div></div><div><div>- probeCounter = startPosition // Frame #.</div>
</div><div><div>- In the probe callback, I always increment the probeCounter and check if it is greater or equal to target frame. If so, I call the notification function.</div></div></blockquote><div><div><br></div><div>
Thanks very much,</div>
<div><br></div>-- <br>Marcus Nascimento<br><br>
</div></div>