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_CLUSTER_BUILDER_H_
6 #define MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
15 Cluster(scoped_ptr
<uint8
[]> data
, int size
);
18 const uint8
* data() const { return data_
.get(); }
19 int size() const { return size_
; }
22 scoped_ptr
<uint8
[]> data_
;
25 DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster
);
28 class ClusterBuilder
{
33 void SetClusterTimecode(int64 cluster_timecode
);
34 void AddSimpleBlock(int track_num
, int64 timecode
, int flags
,
35 const uint8
* data
, int size
);
36 void AddBlockGroup(int track_num
, int64 timecode
, int duration
, int flags
,
37 const uint8
* data
, int size
);
38 void AddBlockGroupWithoutBlockDuration(int track_num
, int64 timecode
,
39 int flags
, const uint8
* data
, int size
);
41 scoped_ptr
<Cluster
> Finish();
42 scoped_ptr
<Cluster
> FinishWithUnknownSize();
45 void AddBlockGroupInternal(int track_num
, int64 timecode
,
46 bool include_block_duration
, int duration
,
47 int flags
, const uint8
* data
, int size
);
49 void ExtendBuffer(int bytes_needed
);
50 void UpdateUInt64(int offset
, int64 value
);
51 void WriteBlock(uint8
* buf
, int track_num
, int64 timecode
, int flags
,
52 const uint8
* data
, int size
);
54 scoped_ptr
<uint8
[]> buffer_
;
57 int64 cluster_timecode_
;
59 DISALLOW_COPY_AND_ASSIGN(ClusterBuilder
);
64 #endif // MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_