本文整理汇总了C++中Maybe::Codecs方法的典型用法代码示例。如果您正苦于以下问题:C++ Maybe::Codecs方法的具体用法?C++ Maybe::Codecs怎么用?C++ Maybe::Codecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Maybe
的用法示例。
在下文中一共展示了Maybe::Codecs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Type
TEST(MediaMIMETypes, MediaExtendedMIMEType)
{
// Some generic tests first.
static const struct
{
const char* mTypeString;
const char* mTypeAsString;
bool mApplication;
bool mAudio;
bool mVideo;
bool mEqualsLiteralVideoSlashMp4; // tests `== "video/mp4"`
bool mHaveCodecs;
} tests[] =
{ // in Type().AsString app audio video ==v/mp4 codecs
{ "video/mp4", "video/mp4", false, false, true, true, false },
{ "video/mp4; codecs=0", "video/mp4", false, false, true, true, true },
{ "VIDEO/MP4", "video/mp4", false, false, true, true, false },
{ "audio/mp4", "audio/mp4", false, true, false, false, false },
{ "application/x", "application/x", true, false, false, false, false }
};
for (const auto& test : tests) {
Maybe<MediaExtendedMIMEType> type = MakeMediaExtendedMIMEType(test.mTypeString);
EXPECT_TRUE(type.isSome())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\").isSome()";
EXPECT_TRUE(type->OriginalString().EqualsASCII(test.mTypeString))
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->AsString() == \"" << test.mTypeAsString << "\"";
EXPECT_TRUE(type->Type().AsString().EqualsASCII(test.mTypeAsString))
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->AsString() == \"" << test.mTypeAsString << "\"";
EXPECT_EQ(test.mApplication, type->Type().HasApplicationMajorType())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type().HasApplicationMajorType() == " << (test.mApplication ? "true" : "false");
EXPECT_EQ(test.mAudio, type->Type().HasAudioMajorType())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type().HasAudioMajorType() == " << (test.mAudio ? "true" : "false");
EXPECT_EQ(test.mVideo, type->Type().HasVideoMajorType())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type().HasVideoMajorType() == " << (test.mVideo ? "true" : "false");
EXPECT_EQ(test.mEqualsLiteralVideoSlashMp4, type->Type() == MEDIAMIMETYPE("video/mp4"))
<< "*MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Type() == MEDIAMIMETYPE(\"video/mp4\")";
EXPECT_EQ(test.mHaveCodecs, type->HaveCodecs())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->HaveCodecs() == " << (test.mHaveCodecs ? "true" : "false");
EXPECT_NE(test.mHaveCodecs, type->Codecs().IsEmpty())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->Codecs.IsEmpty() != " << (test.mHaveCodecs ? "true" : "false");
EXPECT_FALSE(type->GetWidth())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetWidth()";
EXPECT_FALSE(type->GetHeight())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetHeight()";
EXPECT_FALSE(type->GetFramerate())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetFramerate()";
EXPECT_FALSE(type->GetBitrate())
<< "MakeMediaExtendedMIMEType(\"" << test.mTypeString << "\")->GetBitrate()";
}
// Test all extra parameters.
Maybe<MediaExtendedMIMEType> type =
MakeMediaExtendedMIMEType(
"video/mp4; codecs=\"a,b\"; width=1024; Height=768; FrameRate=60; BITRATE=100000");
EXPECT_TRUE(type->HaveCodecs());
EXPECT_FALSE(type->Codecs().IsEmpty());
EXPECT_TRUE(type->Codecs().AsString().EqualsASCII("a,b"));
EXPECT_TRUE(type->Codecs().Contains(NS_LITERAL_STRING("a")));
EXPECT_TRUE(type->Codecs().Contains(NS_LITERAL_STRING("b")));
EXPECT_TRUE(!!type->GetWidth());
EXPECT_EQ(1024, *type->GetWidth());
EXPECT_TRUE(!!type->GetHeight());
EXPECT_EQ(768, *type->GetHeight());
EXPECT_TRUE(!!type->GetFramerate());
EXPECT_EQ(60, *type->GetFramerate());
EXPECT_TRUE(!!type->GetBitrate());
EXPECT_EQ(100000, *type->GetBitrate());
}