Move MoreThanOneTrue/AtLeastOneTrue/OnlyOneTrue to mpd util
Change-Id: I28883808a01d9bf8c115990edbd8b3052c673abb
This commit is contained in:
parent
1d920a1a4e
commit
72ad649ac4
|
@ -107,4 +107,14 @@ bool GetDurationAttribute(xmlNodePtr node, float* duration) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MoreThanOneTrue(bool b1, bool b2, bool b3) {
|
||||||
|
return (b1 && b2) || (b2 && b3) || (b3 && b1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AtLeastOneTrue(bool b1, bool b2, bool b3) { return b1 || b2 || b3; }
|
||||||
|
|
||||||
|
bool OnlyOneTrue(bool b1, bool b2, bool b3) {
|
||||||
|
return !MoreThanOneTrue(b1, b2, b3) && AtLeastOneTrue(b1, b2, b3);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dash_packager
|
} // namespace dash_packager
|
||||||
|
|
|
@ -38,6 +38,10 @@ std::string SecondsToXmlDuration(float seconds);
|
||||||
// Tries to get "duration" attribute from |node|. On success |duration| is set.
|
// Tries to get "duration" attribute from |node|. On success |duration| is set.
|
||||||
bool GetDurationAttribute(xmlNodePtr node, float* duration);
|
bool GetDurationAttribute(xmlNodePtr node, float* duration);
|
||||||
|
|
||||||
|
bool MoreThanOneTrue(bool b1, bool b2, bool b3);
|
||||||
|
bool AtLeastOneTrue(bool b1, bool b2, bool b3);
|
||||||
|
bool OnlyOneTrue(bool b1, bool b2, bool b3);
|
||||||
|
|
||||||
} // namespace dash_packager
|
} // namespace dash_packager
|
||||||
|
|
||||||
#endif // MPD_BASE_MPD_UTILS_H_
|
#endif // MPD_BASE_MPD_UTILS_H_
|
||||||
|
|
|
@ -13,16 +13,6 @@
|
||||||
|
|
||||||
using media::File;
|
using media::File;
|
||||||
|
|
||||||
namespace {
|
|
||||||
bool MoreThanOneTrue(bool b1, bool b2, bool b3) {
|
|
||||||
return (b1 && b2) || (b2 && b3) || (b3 && b1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AtLeastOneTrue(bool b1, bool b2, bool b3) {
|
|
||||||
return (b1 || b2 || b3);
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
namespace dash_packager {
|
namespace dash_packager {
|
||||||
|
|
||||||
SimpleMpdNotifier::SimpleMpdNotifier(DashProfile dash_profile,
|
SimpleMpdNotifier::SimpleMpdNotifier(DashProfile dash_profile,
|
||||||
|
|
|
@ -28,14 +28,6 @@ bool HasText(const MediaInfo& media_info) {
|
||||||
return media_info.text_info().size() > 0;
|
return media_info.text_info().size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MoreThanOneTrue(bool b1, bool b2, bool b3) {
|
|
||||||
return (b1 && b2) || (b2 && b3) || (b3 && b1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OnlyOneTrue(bool b1, bool b2, bool b3) {
|
|
||||||
return !MoreThanOneTrue(b1, b2, b3) && (b1 || b2 || b3);
|
|
||||||
}
|
|
||||||
|
|
||||||
// On entry set |has_video|, |has_audio|, and |has_text| to false.
|
// On entry set |has_video|, |has_audio|, and |has_text| to false.
|
||||||
// On success, return true and set appropriate |has_*| variables. Otherwise
|
// On success, return true and set appropriate |has_*| variables. Otherwise
|
||||||
// return false.
|
// return false.
|
||||||
|
@ -66,7 +58,7 @@ bool HasVideoAudioText(const std::list<MediaInfo>& media_infos,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!OnlyOneTrue(
|
if (!AtLeastOneTrue(
|
||||||
media_info_has_video, media_info_has_audio, media_info_has_text)) {
|
media_info_has_video, media_info_has_audio, media_info_has_text)) {
|
||||||
LOG(ERROR) << "MpdWriter requires that MediaInfo contain one "
|
LOG(ERROR) << "MpdWriter requires that MediaInfo contain one "
|
||||||
"audio, video, or text stream.";
|
"audio, video, or text stream.";
|
||||||
|
|
Loading…
Reference in New Issue