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/media/base/muxer.h"
13 
14 namespace shaka {
15 namespace media {
16 
17 class AudioStreamInfo;
18 class StreamInfo;
19 class VideoStreamInfo;
20 
21 namespace mp4 {
22 
23 class Segmenter;
24 
25 struct ProtectionSchemeInfo;
26 struct Track;
27 
30 class MP4Muxer : public Muxer {
31  public:
33  explicit MP4Muxer(const MuxerOptions& options);
34  ~MP4Muxer() override;
35 
36  private:
37  // Muxer implementation overrides.
38  Status Initialize() override;
39  Status Finalize() override;
40  Status DoAddSample(const MediaStream* stream,
41  std::shared_ptr<MediaSample> sample) override;
42 
43  // Generate Audio/Video Track box.
44  void InitializeTrak(const StreamInfo* info, Track* trak);
45  void GenerateAudioTrak(const AudioStreamInfo* audio_info,
46  Track* trak,
47  uint32_t track_id);
48  void GenerateVideoTrak(const VideoStreamInfo* video_info,
49  Track* trak,
50  uint32_t track_id);
51 
52  // Gets |start| and |end| initialization range. Returns true if there is an
53  // init range and sets start-end byte-range-spec specified in RFC2616.
54  bool GetInitRangeStartAndEnd(uint32_t* start, uint32_t* end);
55 
56  // Gets |start| and |end| index range. Returns true if there is an index range
57  // and sets start-end byte-range-spec specified in RFC2616.
58  bool GetIndexRangeStartAndEnd(uint32_t* start, uint32_t* end);
59 
60  // Fire events if there are no errors and Muxer::muxer_listener() is not NULL.
61  void FireOnMediaStartEvent();
62  void FireOnMediaEndEvent();
63 
64  // Get time in seconds since midnight, Jan. 1, 1904, in UTC Time.
65  uint64_t IsoTimeNow();
66 
67  std::unique_ptr<Segmenter> segmenter_;
68 
69  DISALLOW_COPY_AND_ASSIGN(MP4Muxer);
70 };
71 
72 } // namespace mp4
73 } // namespace media
74 } // namespace shaka
75 
76 #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:82
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:18
Holds video stream information.
Holds audio stream information.