2014-02-14 23:21:05 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
//
|
2014-01-15 18:50:47 +00:00
|
|
|
// Class for reading in MediaInfo from files and writing out an MPD.
|
2014-02-14 23:21:05 +00:00
|
|
|
|
2014-01-15 18:50:47 +00:00
|
|
|
#ifndef MPD_UTIL_MPD_WRITER_H_
|
|
|
|
#define MPD_UTIL_MPD_WRITER_H_
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <string>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/macros.h"
|
2014-01-15 18:50:47 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2014-01-15 18:50:47 +00:00
|
|
|
namespace media {
|
|
|
|
class File;
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2014-01-15 18:50:47 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2014-01-15 18:50:47 +00:00
|
|
|
|
|
|
|
class MediaInfo;
|
|
|
|
|
|
|
|
// An instance of this class takes a set of MediaInfo files and generates an
|
|
|
|
// MPD when one of WriteMpd* methods are called. This generates an MPD with one
|
|
|
|
// <Period> element and at most three <AdaptationSet> elements, each for video,
|
|
|
|
// audio, and text. Information in MediaInfo will be put into one of the
|
|
|
|
// AdaptationSets by checking the video_info, audio_info, and text_info fields.
|
|
|
|
// Therefore, this cannot handle an instance of MediaInfo with video, audio, and
|
|
|
|
// text combination.
|
|
|
|
class MpdWriter {
|
|
|
|
public:
|
|
|
|
MpdWriter();
|
|
|
|
~MpdWriter();
|
|
|
|
|
|
|
|
// Add |file_name| for MPD generation. |file_name| should not be NULL.
|
|
|
|
// The content of |media_info_file| should be a string representation of
|
|
|
|
// MediaInfo, i.e. the content should be a result of using
|
|
|
|
// google::protobuf::TestFormat::Print*() methods.
|
|
|
|
// If necessary, this method can be called after WriteMpd*() methods.
|
|
|
|
bool AddFile(const char* file_name);
|
|
|
|
|
|
|
|
// |base_url| will be used for <BaseURL> element for the MPD. The BaseURL
|
|
|
|
// element will be a direct child element of the <MPD> element.
|
|
|
|
void AddBaseUrl(const std::string& base_url);
|
|
|
|
|
|
|
|
// Write the MPD to |output|. |output| should not be NULL.
|
|
|
|
// AddFile() should be called before calling this function to generate an MPD.
|
|
|
|
// On success, MPD is set to |output| and returns true, otherwise returns
|
|
|
|
// false.
|
|
|
|
// This method can be called multiple times, if necessary.
|
|
|
|
bool WriteMpdToString(std::string* output);
|
|
|
|
|
|
|
|
// Write the MPD to |file_name|. |file_name| should not be NULL.
|
|
|
|
// This opens the file in write mode, IOW if the
|
|
|
|
// file exists this will over write whatever is in the file.
|
|
|
|
// AddFile() should be called before calling this function to generate an MPD.
|
|
|
|
// On success, the MPD gets written to |file| and returns true, otherwise
|
|
|
|
// returns false.
|
|
|
|
// This method can be called multiple times, if necessary.
|
|
|
|
bool WriteMpdToFile(const char* file_name);
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::list<MediaInfo> media_infos_;
|
|
|
|
std::list<std::string> base_urls_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(MpdWriter);
|
|
|
|
};
|
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2014-01-15 18:50:47 +00:00
|
|
|
|
|
|
|
#endif // MPD_UTIL_MPD_WRITER_H_
|