From 72ad649ac4972cc7321276e319d5018802b27469 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Fri, 6 Jun 2014 16:52:06 +0800 Subject: [PATCH] Move MoreThanOneTrue/AtLeastOneTrue/OnlyOneTrue to mpd util Change-Id: I28883808a01d9bf8c115990edbd8b3052c673abb --- mpd/base/mpd_utils.cc | 10 ++++++++++ mpd/base/mpd_utils.h | 4 ++++ mpd/base/simple_mpd_notifier.cc | 10 ---------- mpd/util/mpd_writer.cc | 10 +--------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/mpd/base/mpd_utils.cc b/mpd/base/mpd_utils.cc index 7f6bb34e27..f1fdc2ef31 100644 --- a/mpd/base/mpd_utils.cc +++ b/mpd/base/mpd_utils.cc @@ -107,4 +107,14 @@ bool GetDurationAttribute(xmlNodePtr node, float* duration) { 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 diff --git a/mpd/base/mpd_utils.h b/mpd/base/mpd_utils.h index 3a478b7048..b22969b78f 100644 --- a/mpd/base/mpd_utils.h +++ b/mpd/base/mpd_utils.h @@ -38,6 +38,10 @@ std::string SecondsToXmlDuration(float seconds); // Tries to get "duration" attribute from |node|. On success |duration| is set. 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 #endif // MPD_BASE_MPD_UTILS_H_ diff --git a/mpd/base/simple_mpd_notifier.cc b/mpd/base/simple_mpd_notifier.cc index 992c3f612f..0aa8c5b12a 100644 --- a/mpd/base/simple_mpd_notifier.cc +++ b/mpd/base/simple_mpd_notifier.cc @@ -13,16 +13,6 @@ 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 { SimpleMpdNotifier::SimpleMpdNotifier(DashProfile dash_profile, diff --git a/mpd/util/mpd_writer.cc b/mpd/util/mpd_writer.cc index 3b3d49f321..710cd3b70d 100644 --- a/mpd/util/mpd_writer.cc +++ b/mpd/util/mpd_writer.cc @@ -28,14 +28,6 @@ bool HasText(const MediaInfo& media_info) { 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 success, return true and set appropriate |has_*| variables. Otherwise // return false. @@ -66,7 +58,7 @@ bool HasVideoAudioText(const std::list& media_infos, return false; } - if (!OnlyOneTrue( + if (!AtLeastOneTrue( media_info_has_video, media_info_has_audio, media_info_has_text)) { LOG(ERROR) << "MpdWriter requires that MediaInfo contain one " "audio, video, or text stream.";