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
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#ifndef MEDIA_FORMATS_MP4_MP4_MUXER_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_MP4_MUXER_H_
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2013-12-12 23:49:31 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2017-05-01 23:17:09 +00:00
|
|
|
#include "packager/base/optional.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/base/muxer.h"
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-11-12 20:37:58 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class AudioStreamInfo;
|
|
|
|
class StreamInfo;
|
2015-11-23 23:12:04 +00:00
|
|
|
class TextStreamInfo;
|
2013-11-12 20:37:58 +00:00
|
|
|
class VideoStreamInfo;
|
|
|
|
|
|
|
|
namespace mp4 {
|
|
|
|
|
2014-04-08 20:21:07 +00:00
|
|
|
class Segmenter;
|
2013-11-12 20:37:58 +00:00
|
|
|
|
|
|
|
struct ProtectionSchemeInfo;
|
|
|
|
struct Track;
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Implements MP4 Muxer for ISO-BMFF. Please refer to ISO/IEC 14496-12: ISO
|
|
|
|
/// base media file format for details.
|
2013-11-12 20:37:58 +00:00
|
|
|
class MP4Muxer : public Muxer {
|
|
|
|
public:
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Create a MP4Muxer object from MuxerOptions.
|
2014-01-14 01:38:34 +00:00
|
|
|
explicit MP4Muxer(const MuxerOptions& options);
|
2015-07-22 23:40:45 +00:00
|
|
|
~MP4Muxer() override;
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-09 17:34:55 +00:00
|
|
|
private:
|
|
|
|
// Muxer implementation overrides.
|
2017-02-21 18:36:50 +00:00
|
|
|
Status InitializeMuxer() override;
|
2015-07-22 23:40:45 +00:00
|
|
|
Status Finalize() override;
|
2017-03-03 00:10:30 +00:00
|
|
|
Status AddSample(size_t stream_id,
|
|
|
|
std::shared_ptr<MediaSample> sample) override;
|
|
|
|
Status FinalizeSegment(size_t stream_id,
|
2017-02-24 01:17:47 +00:00
|
|
|
std::shared_ptr<SegmentInfo> segment_info) override;
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2015-12-21 18:34:21 +00:00
|
|
|
// Generate Audio/Video Track box.
|
2013-11-12 20:37:58 +00:00
|
|
|
void InitializeTrak(const StreamInfo* info, Track* trak);
|
|
|
|
void GenerateAudioTrak(const AudioStreamInfo* audio_info,
|
|
|
|
Track* trak,
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t track_id);
|
2013-11-12 20:37:58 +00:00
|
|
|
void GenerateVideoTrak(const VideoStreamInfo* video_info,
|
|
|
|
Track* trak,
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t track_id);
|
2015-11-23 23:12:04 +00:00
|
|
|
void GenerateTextTrak(const TextStreamInfo* video_info,
|
|
|
|
Track* trak,
|
|
|
|
uint32_t track_id);
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2013-12-12 23:49:31 +00:00
|
|
|
// Gets |start| and |end| initialization range. Returns true if there is an
|
|
|
|
// init range and sets start-end byte-range-spec specified in RFC2616.
|
2017-05-01 23:17:09 +00:00
|
|
|
base::Optional<Range> GetInitRangeStartAndEnd();
|
2013-12-12 23:49:31 +00:00
|
|
|
|
|
|
|
// Gets |start| and |end| index range. Returns true if there is an index range
|
|
|
|
// and sets start-end byte-range-spec specified in RFC2616.
|
2017-05-01 23:17:09 +00:00
|
|
|
base::Optional<Range> GetIndexRangeStartAndEnd();
|
2013-12-12 23:49:31 +00:00
|
|
|
|
|
|
|
// Fire events if there are no errors and Muxer::muxer_listener() is not NULL.
|
|
|
|
void FireOnMediaStartEvent();
|
|
|
|
void FireOnMediaEndEvent();
|
|
|
|
|
2014-02-28 02:39:52 +00:00
|
|
|
// Get time in seconds since midnight, Jan. 1, 1904, in UTC Time.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint64_t IsoTimeNow();
|
2014-02-28 02:39:52 +00:00
|
|
|
|
2016-08-17 17:41:40 +00:00
|
|
|
std::unique_ptr<Segmenter> segmenter_;
|
2013-11-12 20:37:58 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(MP4Muxer);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-11-12 20:37:58 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#endif // MEDIA_FORMATS_MP4_MP4_MUXER_H_
|