DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs 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 #include "packager/media/formats/mp4/fourccs.h"
14 
15 namespace edash_packager {
16 namespace media {
17 
18 class AudioStreamInfo;
19 class StreamInfo;
20 class VideoStreamInfo;
21 
22 namespace mp4 {
23 
24 class Segmenter;
25 
26 struct ProtectionSchemeInfo;
27 struct ProtectionSystemSpecificHeader;
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 Initialize() override;
41  Status Finalize() override;
42  Status DoAddSample(const MediaStream* stream,
43  scoped_refptr<MediaSample> sample) override;
44 
45  // Generate Audio/Video Track box.
46  void InitializeTrak(const StreamInfo* info, Track* trak);
47  void GenerateAudioTrak(const AudioStreamInfo* audio_info,
48  Track* trak,
49  uint32_t track_id);
50  void GenerateVideoTrak(const VideoStreamInfo* video_info,
51  Track* trak,
52  uint32_t track_id);
53 
54  // Gets |start| and |end| initialization range. Returns true if there is an
55  // init range and sets start-end byte-range-spec specified in RFC2616.
56  bool GetInitRangeStartAndEnd(uint32_t* start, uint32_t* end);
57 
58  // Gets |start| and |end| index range. Returns true if there is an index range
59  // and sets start-end byte-range-spec specified in RFC2616.
60  bool GetIndexRangeStartAndEnd(uint32_t* start, uint32_t* end);
61 
62  // Fire events if there are no errors and Muxer::muxer_listener() is not NULL.
63  void FireOnMediaStartEvent();
64  void FireOnMediaEndEvent();
65 
66  // Get time in seconds since midnight, Jan. 1, 1904, in UTC Time.
67  uint64_t IsoTimeNow();
68 
69  scoped_ptr<Segmenter> segmenter_;
70 
71  DISALLOW_COPY_AND_ASSIGN(MP4Muxer);
72 };
73 
74 } // namespace mp4
75 } // namespace media
76 } // namespace edash_packager
77 
78 #endif // MEDIA_FORMATS_MP4_MP4_MUXER_H_
MP4Muxer(const MuxerOptions &options)
Create a MP4Muxer object from MuxerOptions.
Definition: mp4_muxer.cc:83
Holds audio stream information.
Abstract class holds stream information.
Definition: stream_info.h:26
Holds video stream information.
This structure contains the list of configuration options for Muxer.
Definition: muxer_options.h:18