本文整理汇总了C++中AP4_Sample::GetCts方法的典型用法代码示例。如果您正苦于以下问题:C++ AP4_Sample::GetCts方法的具体用法?C++ AP4_Sample::GetCts怎么用?C++ AP4_Sample::GetCts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AP4_Sample
的用法示例。
在下文中一共展示了AP4_Sample::GetCts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
/*----------------------------------------------------------------------
| ShowSample
+---------------------------------------------------------------------*/
static void
ShowSample(AP4_Sample& sample, unsigned int index, AP4_SampleDecrypter* sample_decrypter)
{
printf("[%06d] size=%6d duration=%6d",
index,
(int)sample.GetSize(),
(int)sample.GetDuration());
printf(" offset=%10lld dts=%10lld cts=%10lld ",
sample.GetOffset(),
sample.GetDts(),
sample.GetCts());
if (sample.IsSync()) {
printf(" [S] ");
} else {
printf(" ");
}
AP4_DataBuffer sample_data;
sample.ReadData(sample_data);
AP4_DataBuffer* data = &sample_data;
AP4_DataBuffer decrypted_sample_data;
if (sample_decrypter) {
sample_decrypter->DecryptSampleData(sample_data, decrypted_sample_data);
data = & decrypted_sample_data;
}
unsigned int show = data->GetDataSize();
if (show > 12) show = 12; // max first 12 chars
for (unsigned int i=0; i<show; i++) {
printf("%02x", data->GetData()[i]);
}
if (show == data->GetDataSize()) {
printf("\n");
} else {
printf("...\n");
}
}
示例2: failed
/*----------------------------------------------------------------------
| Mp4Parser_Seek
+---------------------------------------------------------------------*/
BLT_METHOD
Mp4Parser_Seek(BLT_MediaNode* _self,
BLT_SeekMode* mode,
BLT_SeekPoint* point)
{
Mp4Parser* self = ATX_SELF_EX(Mp4Parser, BLT_BaseMediaNode, BLT_MediaNode);
/* estimate the seek point */
if (ATX_BASE(self, BLT_BaseMediaNode).context == NULL) return BLT_FAILURE;
BLT_Stream_EstimateSeekPoint(ATX_BASE(self, BLT_BaseMediaNode).context, *mode, point);
if (!(point->mask & BLT_SEEK_POINT_MASK_TIME_STAMP)) {
return BLT_FAILURE;
}
/* seek to the estimated offset on all tracks */
AP4_Ordinal sample_index = 0;
AP4_UI32 ts_ms = point->time_stamp.seconds*1000+point->time_stamp.nanoseconds/1000000;
if (self->video_output.track) {
AP4_Result result = self->video_output.track->GetSampleIndexForTimeStampMs(ts_ms, sample_index);
if (AP4_FAILED(result)) {
ATX_LOG_WARNING_1("video GetSampleIndexForTimeStampMs failed (%d)", result);
return BLT_FAILURE;
}
ATX_LOG_FINE_1("seeking to video time %d ms", ts_ms);
// go to the nearest sync sample
self->video_output.sample = self->video_output.track->GetNearestSyncSampleIndex(sample_index);
if (self->input.reader) {
self->input.reader->SetSampleIndex(self->video_output.track->GetId(), self->video_output.sample);
}
ATX_LOG_FINE_1("seeking to video sync sample %d", self->video_output.sample);
// compute the timestamp of the video sample we're seeking to, so we can pick an audio
// sample that is close in time (there are many more audio sync points than video)
AP4_Sample sample;
if (AP4_SUCCEEDED(self->video_output.track->GetSample(self->video_output.sample, sample))) {
AP4_UI32 media_timescale = self->video_output.track->GetMediaTimeScale();
if (media_timescale) {
ts_ms = (AP4_UI32)((((AP4_UI64)sample.GetCts())*1000)/media_timescale);
ATX_LOG_FINE_1("sync sample time is %d ms", ts_ms);
}
} else {
ATX_LOG_FINE_1("unable to get sample info for sample %d", self->video_output.sample);
}
}
if (self->audio_output.track) {
AP4_Result result = self->audio_output.track->GetSampleIndexForTimeStampMs(ts_ms, sample_index);
if (AP4_FAILED(result)) {
ATX_LOG_WARNING_1("audio GetSampleIndexForTimeStampMs failed (%d)", result);
return BLT_FAILURE;
}
self->audio_output.sample = sample_index;
if (self->input.reader) {
self->input.reader->SetSampleIndex(self->audio_output.track->GetId(), sample_index);
}
}
/* set the mode so that the nodes down the chain know the seek has */
/* already been done on the stream */
*mode = BLT_SEEK_MODE_IGNORE;
return BLT_SUCCESS;
}