Chromium Code Reviews| Index: media/video/encoded_video_source.h |
| diff --git a/media/video/encoded_video_source.h b/media/video/encoded_video_source.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7be3d6b1f65fd8ed31048dcc1de0fccd0db8ae3b |
| --- /dev/null |
| +++ b/media/video/encoded_video_source.h |
| @@ -0,0 +1,111 @@ |
| +// Copyright (c) 2013 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_VIDEO_ENCODED_VIDEO_SOURCE_H_ |
| +#define MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ |
|
hshi1
2013/06/12 18:34:47
I believe you don't really need this header file t
sheu
2013/06/12 19:51:18
It's in here since it's included by some other hea
|
| + |
| +#include "base/memory/ref_counted.h" |
| +#include "media/base/encoded_bitstream_buffer.h" |
| +#include "media/video/video_encode_types.h" |
| + |
| +namespace media { |
| + |
| +// Class to represent encoded video bitstream. |
| +class MEDIA_EXPORT EncodedVideoBitstream : |
| + public base::RefCountedThreadSafe<EncodedVideoBitstream> { |
| + public: |
| + class MEDIA_EXPORT Client { |
| + public: |
| + // After OnStreaming callback stream shall be considered to be streaming. |
| + virtual void OnBitstreamStreaming( |
| + scoped_refptr<EncodedVideoBitstream> bitstream, |
| + const VideoEncodingParameters& params) = 0; |
| + |
| + // After OnRemoved client has to stop using the bitstream object and |
| + // expecting bitstream buffers for that stream. OnRemoved will be called |
| + // also in case of any unrecoverable failure in the capturer. After |
| + // OnRemoved is called from a stream it is guaranteed that that there will |
| + // be no longer pending calls coming in. |
| + virtual void OnBitstreamRemoved( |
| + scoped_refptr<EncodedVideoBitstream> bitstream) = 0; |
| + |
| + // OnBitstreamReady delivers the captured bitstream buffer by buffer to the |
| + // client. |
| + virtual void OnBitstreamReady( |
| + scoped_refptr<EncodedVideoBitstream> bitstream, |
| + scoped_refptr<const EncodedBitstreamBuffer> buffer) = 0; |
| + |
| + // OnBitstreamConfigChanged informs about change in bitstream parameters. |
| + virtual void OnBitstreamConfigChanged( |
| + scoped_refptr<EncodedVideoBitstream> bitstream, |
| + const RuntimeVideoEncodingParameters& params) = 0; |
| + }; |
| + |
| + // TrySetBitstreamConfig issues a reconfiguration request. Old configuration |
| + // must be considered to be the valid configuration until |
| + // OnBitstreamConfigChanged callback has been issued with value signalling |
| + // successful change. |
| + virtual void TryConfigure(const RuntimeVideoEncodingParameters& params) = 0; |
| + |
| + protected: |
| + virtual ~EncodedVideoBitstream() {}; |
| + friend class base::RefCountedThreadSafe<EncodedVideoBitstream>; |
| +}; |
| + |
| +// Class to represent any encoded video source. Anything that provides encoded |
| +// video can be an EncodedVideoSource. Notable examples of this can be video |
| +// encoder and webcam that has encoding capability. |
| +class MEDIA_EXPORT EncodedVideoSource { |
| + public: |
| + |
| + class Observer { |
| + public: |
| + // Invoked when an encoded video source's capabilities become available. |
| + virtual void OnCapabilitiesAvailable(EncodedVideoSource* source) = 0; |
| + |
| + protected: |
| + virtual ~Observer() {} |
| + }; |
| + |
| + virtual ~EncodedVideoSource() {}; |
| + |
| + // Adds/removes observer to receive OnCapabilitiesAvailable notification. |
| + virtual void AddCapabilitiesObserver(Observer* observer) = 0; |
| + virtual void RemoveCapabilitiesObserver(Observer* observer) = 0; |
| + |
| + // StartFetchCapabilities initiates an asynchronous query for the types of |
| + // encoded bitstream supported by the encoder. When the results become |
| + // available, EncodedVideoSource will notify observers via the |
| + // OnCapabilitiesAvailable() method. |
| + virtual void StartFetchCapabilities() = 0; |
| + |
| + // GetCapabilities informs the client what type of encoded bitstream encoder |
| + // is capable to provide. Constraints in the reported capabilities should be |
| + // obeyed when configuring bitstreams. |
| + virtual VideoEncodingCapability GetCapabilities() = 0; |
| + |
| + // OpenBitstream returns object for the stream being added. Client must |
| + // consider the returned stream valid until OnBitstreamRemoved callback is |
| + // called with the id. Client should check the parameters agains limits |
| + // reported by GetCapabilities before trying to issue an request to add an |
| + // encoded bitstream. EncodedVideoSource retains the ownership of |
| + // EncodedVideoBitstream and client just has the pointer to it. |
| + virtual scoped_refptr<EncodedVideoBitstream> OpenBitstream( |
| + EncodedVideoBitstream::Client* client, |
| + const VideoEncodingParameters& params) = 0; |
| + // CloseBitstream removes the bitstream. |
| + virtual void CloseBitstream( |
| + scoped_refptr<media::EncodedVideoBitstream> bitstream) = 0; |
| + |
| + // ReturnBitstreamBuffer notifies that the data within the buffer has been |
| + // processed and it can be reused to encode upcoming bitstream. |
| + virtual void ReturnBitstreamBuffer( |
| + scoped_refptr<media::EncodedVideoBitstream> bitstream, |
| + scoped_refptr<const media::EncodedBitstreamBuffer> buffer) = 0; |
| +}; |
| + |
| +} // namespace media |
| + |
| +#endif // MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ |
| + |