DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
mp4_muxer.h
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FORMATS_MP4_MP4_MUXER_H_
8 #define MEDIA_FORMATS_MP4_MP4_MUXER_H_
9 
10 #include <vector>
11 
12 #include "packager/base/optional.h"
13 #include "packager/media/base/muxer.h"
14 
15 namespace shaka {
16 namespace media {
17 
18 class AudioStreamInfo;
19 class StreamInfo;
20 class TextStreamInfo;
21 class VideoStreamInfo;
22 
23 namespace mp4 {
24 
25 class Segmenter;
26 
27 struct ProtectionSchemeInfo;
28 struct Track;
29 
32 class MP4Muxer : public Muxer {
33  public:
35  explicit MP4Muxer(const MuxerOptions& options);
36  ~MP4Muxer() override;
37 
38  private:
39  // Muxer implementation overrides.
40  Status InitializeMuxer() override;
41  Status Finalize() override;
42  Status AddSample(size_t stream_id,
43  std::shared_ptr<MediaSample> sample) override;
44  Status FinalizeSegment(size_t stream_id,
45  std::shared_ptr<SegmentInfo> segment_info) override;
46 
47  // Generate Audio/Video Track box.
48  void InitializeTrak(const StreamInfo* info, Track* trak);
49  void GenerateAudioTrak(const AudioStreamInfo* audio_info,
50  Track* trak,
51  uint32_t track_id);
52  void GenerateVideoTrak(const VideoStreamInfo* video_info,
53  Track* trak,
54  uint32_t track_id);
55  void GenerateTextTrak(const TextStreamInfo* video_info,
56  Track* trak,
57  uint32_t track_id);
58 
59  // Gets |start| and |end| initialization range. Returns true if there is an
60  // init range and sets start-end byte-range-spec specified in RFC2616.
61  base::Optional<Range> GetInitRangeStartAndEnd();
62 
63  // Gets |start| and |end| index range. Returns true if there is an index range
64  // and sets start-end byte-range-spec specified in RFC2616.
65  base::Optional<Range> GetIndexRangeStartAndEnd();
66 
67  // Fire events if there are no errors and Muxer::muxer_listener() is not NULL.
68  void FireOnMediaStartEvent();
69  void FireOnMediaEndEvent();
70 
71  // Get time in seconds since midnight, Jan. 1, 1904, in UTC Time.
72  uint64_t IsoTimeNow();
73 
74  std::unique_ptr<Segmenter> segmenter_;
75 
76  DISALLOW_COPY_AND_ASSIGN(MP4Muxer);
77 };
78 
79 } // namespace mp4
80 } // namespace media
81 } // namespace shaka
82 
83 #endif // MEDIA_FORMATS_MP4_MP4_MUXER_H_
Abstract class holds stream information.
Definition: stream_info.h:57
MP4Muxer(const MuxerOptions &options)
Create a MP4Muxer object from MuxerOptions.
Definition: mp4_muxer.cc:108
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:18
Holds video stream information.
Holds audio stream information.