OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ |
| 6 #define MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "media/base/encoded_bitstream_buffer.h" |
| 10 #include "media/video/video_encode_types.h" |
| 11 |
| 12 namespace media { |
| 13 |
| 14 // Class to represent any encoded video source. Anything that provides encoded |
| 15 // video can be an EncodedVideoSource. Notable examples of this can be video |
| 16 // encoder and webcam that has encoding capabilities. |
| 17 // TODO(hshi): merge this with VEA interface. http://crbug.com/248334. |
| 18 class EncodedVideoSource { |
| 19 public: |
| 20 class Client { |
| 21 public: |
| 22 // Notifies client that bitstream is opened successfully. The |params| |
| 23 // contains the actual encoding parameters chosen by the browser process. |
| 24 // It may be different from the params requested in OpenBitstream(). |
| 25 virtual void OnOpened(const VideoEncodingParameters& params) = 0; |
| 26 |
| 27 // Notifies client that bitstream is closed. After this call it is |
| 28 // guaranteed that client will not receive further calls. |
| 29 virtual void OnClosed() = 0; |
| 30 |
| 31 // Delivers an encoded bitstream buffer to the client. |
| 32 virtual void OnBufferReady( |
| 33 scoped_refptr<const EncodedBitstreamBuffer> buffer) = 0; |
| 34 |
| 35 // Notifies client that encoding parameters has changed. The |params| |
| 36 // contains the current encoding parameters chosen by the browser process. |
| 37 // It may be different from the params requested in TrySetBitstreamConfig(). |
| 38 virtual void OnConfigChanged( |
| 39 const RuntimeVideoEncodingParameters& params) = 0; |
| 40 }; |
| 41 |
| 42 // Callback is invoked once RequestCapabilities() is complete. |
| 43 typedef base::Callback<void(const VideoEncodingCapabilities& capabilities)> |
| 44 RequestCapabilitiesCallback; |
| 45 |
| 46 // RequestCapabilities initiates an asynchronous query for the types of |
| 47 // encoded bitstream supported by the encoder. This call should be invoked |
| 48 // only once. EncodedVideoSource will invoke |callback| when capabilities |
| 49 // become available. |
| 50 virtual void RequestCapabilities( |
| 51 const RequestCapabilitiesCallback& callback) = 0; |
| 52 |
| 53 // OpenBitstream opens the bitstream on the encoded video source. Only one |
| 54 // bitstream can be opened for an encoded video source. |
| 55 virtual void OpenBitstream(Client* client, |
| 56 const VideoEncodingParameters& params) = 0; |
| 57 |
| 58 // CloseBitstream closes the bitstream. |
| 59 virtual void CloseBitstream() = 0; |
| 60 |
| 61 // ReturnBitstreamBuffer notifies that the data within the buffer has been |
| 62 // processed and it can be reused to encode upcoming bitstream. |
| 63 virtual void ReturnBitstreamBuffer( |
| 64 scoped_refptr<const media::EncodedBitstreamBuffer> buffer) = 0; |
| 65 |
| 66 // TrySetBitstreamConfig requests to change encoding parameters. Old config |
| 67 // must be considered valid until OnConfigChanged is invoked on the client |
| 68 // signaling successful change. |
| 69 virtual void TrySetBitstreamConfig( |
| 70 const RuntimeVideoEncodingParameters& params) = 0; |
| 71 }; |
| 72 |
| 73 } // namespace media |
| 74 |
| 75 #endif // MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ |
| 76 |
OLD | NEW |