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. 4 5 #ifndef CHROMECAST_MEDIA_CMA_BASE_CODED_FRAME_PROVIDER_H_ 6 #define CHROMECAST_MEDIA_CMA_BASE_CODED_FRAME_PROVIDER_H_ 7 8 #include "base/callback.h" 9 #include "base/macros.h" 10 #include "base/memory/ref_counted.h" 11 12 namespace media { 13 class AudioDecoderConfig; 14 class VideoDecoderConfig; 15 } 16 17 namespace chromecast { 18 namespace media { 19 class DecoderBufferBase; 20 21 class CodedFrameProvider { 22 public: 23 typedef base::Callback<void(const scoped_refptr<DecoderBufferBase>&, 24 const ::media::AudioDecoderConfig&, 25 const ::media::VideoDecoderConfig&)> ReadCB; 26 27 CodedFrameProvider(); 28 virtual ~CodedFrameProvider(); 29 30 // Request a coded frame which is provided asynchronously through callback 31 // |read_cb|. 32 // If the frame is associated with a new video/audio configuration, 33 // these configurations are returned as part of the |read_cb| callback. 34 // Invoking the |read_cb| callback with invalid audio/video configurations 35 // means the configurations have not changed. 36 virtual void Read(const ReadCB& read_cb) = 0; 37 38 // Flush the coded frames held by the frame provider. 39 // Invoke callback |flush_cb| when completed. 40 // Note: any pending read is cancelled, meaning that any pending |read_cb| 41 // callback will not be invoked. 42 virtual void Flush(const base::Closure& flush_cb) = 0; 43 44 private: 45 DISALLOW_COPY_AND_ASSIGN(CodedFrameProvider); 46 }; 47 48 } // namespace media 49 } // namespace chromecast 50 51 #endif // CHROMECAST_MEDIA_CMA_BASE_CODED_FRAME_PROVIDER_H_ 52