1 // Copyright 2020 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.
4 
5 #ifndef CHROMECAST_MEDIA_BASE_CAST_DECODER_BUFFER_IMPL_H_
6 #define CHROMECAST_MEDIA_BASE_CAST_DECODER_BUFFER_IMPL_H_
7 
8 #include "base/time/time.h"
9 #include "chromecast/media/api/decoder_buffer_base.h"
10 
11 namespace chromecast {
12 namespace media {
13 
14 class CastDecoderBufferImpl : public DecoderBufferBase {
15  public:
16   // Using explicit constructor without providing stream id will set it to
17   // kPrimary by default.
18   explicit CastDecoderBufferImpl(size_t size);
19   CastDecoderBufferImpl(size_t size, StreamId stream_id);
20 
21   static scoped_refptr<CastDecoderBufferImpl> CreateEOSBuffer();
22   static scoped_refptr<CastDecoderBufferImpl> CreateEOSBuffer(
23       StreamId stream_id);
24 
25   // DecoderBufferBase implementation:
26   StreamId stream_id() const override;
27   int64_t timestamp() const override;
28   void set_timestamp(base::TimeDelta timestamp) override;
29   const uint8_t* data() const override;
30   uint8_t* writable_data() const override;
31   size_t data_size() const override;
32   const CastDecryptConfig* decrypt_config() const override;
33   bool end_of_stream() const override;
34 
35  private:
36   // This constructor is used by CreateEOSBuffer.
37   explicit CastDecoderBufferImpl(StreamId stream_id);
38   ~CastDecoderBufferImpl() override;
39 
40   const StreamId stream_id_;
41   const size_t size_;
42   const std::unique_ptr<uint8_t[]> data_;
43   base::TimeDelta timestamp_;
44 };
45 
46 }  // namespace media
47 }  // namespace chromecast
48 
49 #endif  // CHROMECAST_MEDIA_BASE_CAST_DECODER_BUFFER_IMPL_H_
50