7 #include "packager/mpd/base/mpd_notifier_util.h"
9 #include "packager/base/strings/string_number_conversions.h"
10 #include "packager/base/strings/string_util.h"
11 #include "packager/media/file/file.h"
12 #include "packager/media/file/file_closer.h"
13 #include "packager/mpd/base/mpd_utils.h"
18 using media::FileCloser;
21 CHECK(!output_path.empty());
25 LOG(ERROR) <<
"Failed to write MPD to string.";
29 std::unique_ptr<File, FileCloser> file(File::Open(output_path.c_str(),
"w"));
31 LOG(ERROR) <<
"Failed to open file for writing: " << output_path;
35 const char* mpd_char_ptr = mpd.data();
36 size_t mpd_bytes_left = mpd.size();
37 while (mpd_bytes_left > 0) {
38 int64_t length = file->Write(mpd_char_ptr, mpd_bytes_left);
40 LOG(ERROR) <<
"Failed to write to file '" << output_path <<
"' ("
44 mpd_char_ptr += length;
45 mpd_bytes_left -= length;
48 return file.release()->Close();
52 const bool has_video = media_info.has_video_info();
53 const bool has_audio = media_info.has_audio_info();
54 const bool has_text = media_info.has_text_info();
56 if (MoreThanOneTrue(has_video, has_audio, has_text)) {
57 NOTIMPLEMENTED() <<
"MediaInfo with more than one stream is not supported.";
58 return kContentTypeUnknown;
60 if (!AtLeastOneTrue(has_video, has_audio, has_text)) {
61 LOG(ERROR) <<
"MediaInfo should contain one audio, video, or text stream.";
62 return kContentTypeUnknown;
64 return has_video ? kContentTypeVideo
65 : (has_audio ? kContentTypeAudio : kContentTypeText);
70 std::string input_in_string(input.begin(), input.end());
71 base::Base64Encode(input_in_string, &output);
This class generates DASH MPDs (Media Presentation Descriptions).
std::string Uint8VectorToBase64(const std::vector< uint8_t > &input)
Converts uint8 vector into base64 encoded string.
virtual bool ToString(std::string *output)
ContentType GetContentType(const MediaInfo &media_info)
bool WriteMpdToFile(const std::string &output_path, MpdBuilder *mpd_builder)