2015-10-08 21:48:07 +00:00
|
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_
|
|
|
|
#define MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_
|
|
|
|
|
2015-10-14 22:46:23 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include "packager/base/memory/scoped_ptr.h"
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2015-10-08 21:48:07 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class Cluster {
|
|
|
|
public:
|
2015-10-14 22:46:23 +00:00
|
|
|
Cluster(scoped_ptr<uint8_t[]> data, int size);
|
2015-10-08 21:48:07 +00:00
|
|
|
~Cluster();
|
|
|
|
|
2015-10-14 22:46:23 +00:00
|
|
|
const uint8_t* data() const { return data_.get(); }
|
2015-10-08 21:48:07 +00:00
|
|
|
int size() const { return size_; }
|
|
|
|
|
|
|
|
private:
|
2015-10-14 22:46:23 +00:00
|
|
|
scoped_ptr<uint8_t[]> data_;
|
2015-10-08 21:48:07 +00:00
|
|
|
int size_;
|
|
|
|
|
|
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(Cluster);
|
|
|
|
};
|
|
|
|
|
|
|
|
class ClusterBuilder {
|
|
|
|
public:
|
|
|
|
ClusterBuilder();
|
|
|
|
~ClusterBuilder();
|
|
|
|
|
2015-10-14 22:46:23 +00:00
|
|
|
void SetClusterTimecode(int64_t cluster_timecode);
|
|
|
|
void AddSimpleBlock(int track_num,
|
|
|
|
int64_t timecode,
|
|
|
|
int flags,
|
|
|
|
const uint8_t* data,
|
|
|
|
int size);
|
|
|
|
void AddBlockGroup(int track_num,
|
|
|
|
int64_t timecode,
|
|
|
|
int duration,
|
|
|
|
int flags,
|
|
|
|
const uint8_t* data,
|
|
|
|
int size);
|
|
|
|
void AddBlockGroupWithoutBlockDuration(int track_num,
|
|
|
|
int64_t timecode,
|
|
|
|
int flags,
|
|
|
|
const uint8_t* data,
|
|
|
|
int size);
|
2015-10-08 21:48:07 +00:00
|
|
|
|
|
|
|
scoped_ptr<Cluster> Finish();
|
|
|
|
scoped_ptr<Cluster> FinishWithUnknownSize();
|
|
|
|
|
|
|
|
private:
|
2015-10-14 22:46:23 +00:00
|
|
|
void AddBlockGroupInternal(int track_num,
|
|
|
|
int64_t timecode,
|
|
|
|
bool include_block_duration,
|
|
|
|
int duration,
|
|
|
|
int flags,
|
|
|
|
const uint8_t* data,
|
|
|
|
int size);
|
2015-10-08 21:48:07 +00:00
|
|
|
void Reset();
|
|
|
|
void ExtendBuffer(int bytes_needed);
|
2015-10-14 22:46:23 +00:00
|
|
|
void UpdateUInt64(int offset, int64_t value);
|
|
|
|
void WriteBlock(uint8_t* buf,
|
|
|
|
int track_num,
|
|
|
|
int64_t timecode,
|
|
|
|
int flags,
|
|
|
|
const uint8_t* data,
|
|
|
|
int size);
|
2015-10-08 21:48:07 +00:00
|
|
|
|
2015-10-14 22:46:23 +00:00
|
|
|
scoped_ptr<uint8_t[]> buffer_;
|
2015-10-08 21:48:07 +00:00
|
|
|
int buffer_size_;
|
|
|
|
int bytes_used_;
|
2015-10-14 22:46:23 +00:00
|
|
|
int64_t cluster_timecode_;
|
2015-10-08 21:48:07 +00:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(ClusterBuilder);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2015-10-08 21:48:07 +00:00
|
|
|
|
|
|
|
#endif // MEDIA_FORMATS_WEBM_CLUSTER_BUILDER_H_
|