本文整理汇总了C++中sp::countTracks方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::countTracks方法的具体用法?C++ sp::countTracks怎么用?C++ sp::countTracks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::countTracks方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
uint32_t
MP4MetadataStagefright::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const
{
size_t tracks = mMetadataExtractor->countTracks();
uint32_t total = 0;
for (size_t i = 0; i < tracks; i++) {
sp<MetaData> metaData = mMetadataExtractor->getTrackMetaData(i);
const char* mimeType;
if (metaData == nullptr || !metaData->findCString(kKeyMIMEType, &mimeType)) {
continue;
}
switch (aType) {
case mozilla::TrackInfo::kAudioTrack:
if (!strncmp(mimeType, "audio/", 6) &&
CheckTrack(mimeType, metaData.get(), i)) {
total++;
}
break;
case mozilla::TrackInfo::kVideoTrack:
if (!strncmp(mimeType, "video/", 6) &&
CheckTrack(mimeType, metaData.get(), i)) {
total++;
}
break;
default:
break;
}
}
return total;
}
示例2: while
mozilla::UniquePtr<mozilla::TrackInfo>
MP4MetadataStagefright::GetTrackInfo(mozilla::TrackInfo::TrackType aType,
size_t aTrackNumber) const
{
size_t tracks = mMetadataExtractor->countTracks();
if (!tracks) {
return nullptr;
}
int32_t index = -1;
const char* mimeType;
sp<MetaData> metaData;
size_t i = 0;
while (i < tracks) {
metaData = mMetadataExtractor->getTrackMetaData(i);
if (metaData == nullptr || !metaData->findCString(kKeyMIMEType, &mimeType)) {
continue;
}
switch (aType) {
case mozilla::TrackInfo::kAudioTrack:
if (!strncmp(mimeType, "audio/", 6) &&
CheckTrack(mimeType, metaData.get(), i)) {
index++;
}
break;
case mozilla::TrackInfo::kVideoTrack:
if (!strncmp(mimeType, "video/", 6) &&
CheckTrack(mimeType, metaData.get(), i)) {
index++;
}
break;
default:
break;
}
if (index == aTrackNumber) {
break;
}
i++;
}
if (index < 0) {
return nullptr;
}
UniquePtr<mozilla::TrackInfo> e = CheckTrack(mimeType, metaData.get(), index);
if (e) {
metaData = mMetadataExtractor->getMetaData();
int64_t movieDuration;
if (!e->mDuration &&
metaData->findInt64(kKeyMovieDuration, &movieDuration)) {
// No duration in track, use movie extend header box one.
e->mDuration = movieDuration;
}
}
return e;
}
示例3: Init
bool OmxDecoder::Init(sp<MediaExtractor>& extractor) {
#ifdef PR_LOGGING
if (!gOmxDecoderLog) {
gOmxDecoderLog = PR_NewLogModule("OmxDecoder");
}
#endif
const char* extractorMime;
sp<MetaData> meta = extractor->getMetaData();
ssize_t audioTrackIndex = -1;
ssize_t videoTrackIndex = -1;
for (size_t i = 0; i < extractor->countTracks(); ++i) {
sp<MetaData> meta = extractor->getTrackMetaData(i);
int32_t bitRate;
if (!meta->findInt32(kKeyBitRate, &bitRate))
bitRate = 0;
const char *mime;
if (!meta->findCString(kKeyMIMEType, &mime)) {
continue;
}
if (videoTrackIndex == -1 && !strncasecmp(mime, "video/", 6)) {
videoTrackIndex = i;
} else if (audioTrackIndex == -1 && !strncasecmp(mime, "audio/", 6)) {
audioTrackIndex = i;
}
}
if (videoTrackIndex == -1 && audioTrackIndex == -1) {
NS_WARNING("OMX decoder could not find video or audio tracks");
return false;
}
mResource->SetReadMode(MediaCacheStream::MODE_PLAYBACK);
if (videoTrackIndex != -1) {
mVideoTrack = extractor->getTrack(videoTrackIndex);
}
if (audioTrackIndex != -1) {
mAudioTrack = extractor->getTrack(audioTrackIndex);
#ifdef MOZ_AUDIO_OFFLOAD
// mAudioTrack is be used by OMXCodec. For offloaded audio track, using same
// object gives undetermined behavior. So get a new track
mAudioOffloadTrack = extractor->getTrack(audioTrackIndex);
#endif
}
return true;
}
示例4:
int32_t
MP4MetadataStagefright::GetTrackNumber(mozilla::TrackID aTrackID)
{
size_t numTracks = mMetadataExtractor->countTracks();
for (size_t i = 0; i < numTracks; i++) {
sp<MetaData> metaData = mMetadataExtractor->getTrackMetaData(i);
if (!metaData.get()) {
continue;
}
int32_t value;
if (metaData->findInt32(kKeyTrackID, &value) && value == aTrackID) {
return i;
}
}
return -1;
}
示例5: if
bool
OmxDecoder::Init(sp<MediaExtractor>& extractor) {
sp<MetaData> meta = extractor->getMetaData();
ssize_t audioTrackIndex = -1;
ssize_t videoTrackIndex = -1;
for (size_t i = 0; i < extractor->countTracks(); ++i) {
sp<MetaData> meta = extractor->getTrackMetaData(i);
int32_t bitRate;
if (!meta->findInt32(kKeyBitRate, &bitRate))
bitRate = 0;
const char *mime;
if (!meta->findCString(kKeyMIMEType, &mime)) {
continue;
}
if (videoTrackIndex == -1 && !strncasecmp(mime, "video/", 6)) {
videoTrackIndex = i;
} else if (audioTrackIndex == -1 && !strncasecmp(mime, "audio/", 6)) {
audioTrackIndex = i;
}
}
if (videoTrackIndex == -1 && audioTrackIndex == -1) {
NS_WARNING("OMX decoder could not find video or audio tracks");
return false;
}
if (videoTrackIndex != -1 && mDecoder->GetImageContainer()) {
mVideoTrack = extractor->getTrack(videoTrackIndex);
}
if (audioTrackIndex != -1) {
mAudioTrack = extractor->getTrack(audioTrackIndex);
#ifdef MOZ_AUDIO_OFFLOAD
// mAudioTrack is be used by OMXCodec. For offloaded audio track, using same
// object gives undetermined behavior. So get a new track
mAudioOffloadTrack = extractor->getTrack(audioTrackIndex);
#endif
}
return true;
}
示例6: GetTrackNumber
bool
MP4MetadataStagefright::ReadTrackIndex(FallibleTArray<Index::Indice>& aDest, mozilla::TrackID aTrackID)
{
size_t numTracks = mMetadataExtractor->countTracks();
int32_t trackNumber = GetTrackNumber(aTrackID);
if (trackNumber < 0) {
return false;
}
sp<MediaSource> track = mMetadataExtractor->getTrack(trackNumber);
if (!track.get()) {
return false;
}
sp<MetaData> metadata = mMetadataExtractor->getTrackMetaData(trackNumber);
int64_t mediaTime;
if (!metadata->findInt64(kKeyMediaTime, &mediaTime)) {
mediaTime = 0;
}
bool rv = ConvertIndex(aDest, track->exportIndex(), mediaTime);
return rv;
}
示例7: CHECK
int
CPlayerClient::foundMediaFile(const char *path, sp<IMediaExtractor>& pExtractor_in)
{
AUTO_LOG();
CHECK_PTR_EXT(path, BAD_VALUE);
CHECK_PTR_EXT(pExtractor_in, BAD_VALUE);
CHECK_PTR_EXT(m_pSink, BAD_VALUE);
for (size_t i = 0; i < pExtractor_in->countTracks(); ++i) {
sp<MetaData> meta = pExtractor_in->getTrackMetaData(i);
CHECK_PTR_EXT(meta, BAD_VALUE);
const char *_mime;
CHECK(meta->findCString(kKeyMIMEType, &_mime));
CHECK_PTR_EXT(_mime, BAD_VALUE);
String8 mime = String8(_mime);
if (!strncasecmp(mime.string(), "audio/", 6)) {
AudioPlayer *player = new AudioPlayer(m_pSink);
CHECK_PTR_EXT(player, BAD_VALUE);
player->setSource(pExtractor_in->getTrack(i));
player->start(false /* sourceAlreadyStarted */);
//status_t finalStatus;
//while (!player->reachedEOS(&finalStatus)) {
// usleep(100000ll);
//}
delete player;
player = NULL;
}
}
RETURN(OK);
}