| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_WEBM_CLUSTER_BUILDER_H_ | 5 #ifndef MEDIA_WEBM_CLUSTER_BUILDER_H_ |
| 6 #define MEDIA_WEBM_CLUSTER_BUILDER_H_ | 6 #define MEDIA_WEBM_CLUSTER_BUILDER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 class Cluster { | 14 class Cluster { |
| 15 public: | 15 public: |
| 16 // Takes ownership of |data| | 16 Cluster(scoped_array<uint8> data, int size); |
| 17 Cluster(const uint8* data, int size); | |
| 18 ~Cluster(); | 17 ~Cluster(); |
| 19 | 18 |
| 20 const uint8* data() const { return data_.get(); } | 19 const uint8* data() const { return data_.get(); } |
| 21 int size() const { return size_; } | 20 int size() const { return size_; } |
| 22 | 21 |
| 23 private: | 22 private: |
| 24 scoped_array<const uint8> data_; | 23 scoped_array<uint8> data_; |
| 25 int size_; | 24 int size_; |
| 26 | 25 |
| 27 DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster); | 26 DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster); |
| 28 }; | 27 }; |
| 29 | 28 |
| 30 class ClusterBuilder { | 29 class ClusterBuilder { |
| 31 public: | 30 public: |
| 32 ClusterBuilder(); | 31 ClusterBuilder(); |
| 33 ~ClusterBuilder(); | 32 ~ClusterBuilder(); |
| 34 | 33 |
| 35 void SetClusterTimecode(int64 cluster_timecode); | 34 void SetClusterTimecode(int64 cluster_timecode); |
| 36 void AddSimpleBlock(int track_num, int64 timecode, int flags, | 35 void AddSimpleBlock(int track_num, int64 timecode, int flags, |
| 37 const uint8* data, int size); | 36 const uint8* data, int size); |
| 38 | 37 |
| 39 Cluster* Finish(); | 38 scoped_ptr<Cluster> Finish(); |
| 40 | 39 |
| 41 private: | 40 private: |
| 42 void Reset(); | 41 void Reset(); |
| 43 void ExtendBuffer(int bytes_needed); | 42 void ExtendBuffer(int bytes_needed); |
| 44 void UpdateUInt64(int offset, int64 value); | 43 void UpdateUInt64(int offset, int64 value); |
| 45 | 44 |
| 46 scoped_array<uint8> buffer_; | 45 scoped_array<uint8> buffer_; |
| 47 int buffer_size_; | 46 int buffer_size_; |
| 48 int bytes_used_; | 47 int bytes_used_; |
| 49 int64 cluster_timecode_; | 48 int64 cluster_timecode_; |
| 50 | 49 |
| 51 DISALLOW_COPY_AND_ASSIGN(ClusterBuilder); | 50 DISALLOW_COPY_AND_ASSIGN(ClusterBuilder); |
| 52 }; | 51 }; |
| 53 | 52 |
| 54 } // namespace media | 53 } // namespace media |
| 55 | 54 |
| 56 #endif // MEDIA_WEBM_CLUSTER_BUILDER_H_ | 55 #endif // MEDIA_WEBM_CLUSTER_BUILDER_H_ |
| OLD | NEW |