1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_FORMATS_WEBM_TRACKS_BUILDER_H_
6 #define MEDIA_FORMATS_WEBM_TRACKS_BUILDER_H_
12 #include "base/basictypes.h"
18 // If |allow_invalid_values| is false, some AddTrack() parameters will be
19 // basically checked and will assert if out of valid range. |codec_id|,
20 // |name|, |language| and any device-specific constraints are not checked.
21 explicit TracksBuilder(bool allow_invalid_values
);
22 TracksBuilder(); // Sets |allow_invalid_values| to false.
25 // Only a non-negative |default_duration| will result in a serialized
26 // kWebMIdDefaultDuration element. Note, 0 is allowed here for testing only
27 // if |allow_invalid_values_| is true, since it is an illegal value for
28 // DefaultDuration. Similar applies to |audio_channels|,
29 // |audio_sampling_frequency|, |video_pixel_width| and |video_pixel_height|.
30 void AddVideoTrack(int track_num
,
32 const std::string
& codec_id
,
33 const std::string
& name
,
34 const std::string
& language
,
36 int video_pixel_width
,
37 int video_pixel_height
);
38 void AddAudioTrack(int track_num
,
40 const std::string
& codec_id
,
41 const std::string
& name
,
42 const std::string
& language
,
45 double audio_sampling_frequency
);
46 void AddTextTrack(int track_num
,
48 const std::string
& codec_id
,
49 const std::string
& name
,
50 const std::string
& language
);
52 std::vector
<uint8
> Finish();
55 void AddTrackInternal(int track_num
,
58 const std::string
& codec_id
,
59 const std::string
& name
,
60 const std::string
& language
,
62 int video_pixel_width
,
63 int video_pixel_height
,
65 double audio_sampling_frequency
);
66 int GetTracksSize() const;
67 int GetTracksPayloadSize() const;
68 void WriteTracks(uint8
* buffer
, int buffer_size
) const;
75 const std::string
& codec_id
,
76 const std::string
& name
,
77 const std::string
& language
,
79 int video_pixel_width
,
80 int video_pixel_height
,
82 double audio_sampling_frequency
,
83 bool allow_invalid_values
);
86 void Write(uint8
** buf
, int* buf_size
) const;
88 int GetPayloadSize() const;
89 int GetVideoPayloadSize() const;
90 int GetAudioPayloadSize() const;
95 std::string codec_id_
;
97 std::string language_
;
98 int default_duration_
;
99 int video_pixel_width_
;
100 int video_pixel_height_
;
102 double audio_sampling_frequency_
;
105 typedef std::list
<Track
> TrackList
;
107 bool allow_invalid_values_
;
109 DISALLOW_COPY_AND_ASSIGN(TracksBuilder
);
114 #endif // MEDIA_FORMATS_WEBM_TRACKS_BUILDER_H_