Chromium Code Reviews| 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 an encoded video bitstream which originates from an | |
| 15 // EncodedVideoSource. The interface is usually obtained through initialization | |
| 16 // with OpenBitstream call to EncodedVideoSource. Each EncodedVideoBitstream | |
| 17 // instance has only one client, but there can be multiple EncodedVideoBitstream | |
| 18 // objects representing the same concrete bitstream from a EncodedVideoSource. | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
What is the concrete use-case here?
Ville-Mikko Rautio
2013/03/19 16:45:43
E.g. considering two peerconnections on the same p
| |
| 19 // | |
| 20 // Client can close the bitstream simply by discarding the scoped_refptr to the | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
How does this work? The concrete impl of EVB will
Ville-Mikko Rautio
2013/03/19 16:45:43
I implemented it by having proxy object (owned by
| |
| 21 // object. Also, if client receives OnRemoved callback from the bitstream, it | |
| 22 // should consider bitstream instance invalid and can discard the pointer to it. | |
| 23 class MEDIA_EXPORT EncodedVideoBitstream : | |
| 24 public base::RefCountedThreadSafe<EncodedVideoBitstream> { | |
| 25 public: | |
| 26 class MEDIA_EXPORT Client { | |
| 27 public: | |
| 28 // After OnStreaming callback stream shall be considered to be streaming. | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
Comment style is unstylish. Specifically here I'm
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
doco modifiable, probably rename to "is_mutable".
Ville-Mikko Rautio
2013/03/19 16:45:43
Done.
Ville-Mikko Rautio
2013/03/19 16:45:43
Done.
| |
| 29 virtual void OnStreaming( | |
| 30 scoped_refptr<EncodedVideoBitstream> bitstream, bool modifiable) = 0; | |
| 31 | |
| 32 // After OnRemoved client has to stop using the bitstream object and | |
| 33 // expecting bitstream buffers for that stream. OnRemoved will be called | |
| 34 // also in case of any unrecoverable failure in the device. After | |
| 35 // OnRemoved is called for a bitstream it is guaranteed that that there will | |
| 36 // be no longer pending calls coming in to the client. | |
| 37 virtual void OnRemoved(scoped_refptr<EncodedVideoBitstream> bitstream) = 0; | |
| 38 | |
| 39 // OnBufferReady delivers the captured bitstream buffer by buffer to the | |
| 40 // client. | |
| 41 virtual void OnBufferReady( | |
| 42 scoped_refptr<EncodedVideoBitstream> bitstream, | |
| 43 scoped_refptr<const EncodedBitstreamBuffer> buffer) = 0; | |
| 44 | |
| 45 // OnConfigChanged informs about change in bitstream parameters that can | |
| 46 // change during runtime. | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
What about the initial parameters? Shouldn't they
Ville-Mikko Rautio
2013/03/19 16:45:43
Original idea was that if parameters given in Open
| |
| 47 virtual void OnConfigChanged( | |
| 48 scoped_refptr<EncodedVideoBitstream> bitstream, | |
| 49 const RuntimeVideoEncodingParameters& params) = 0; | |
| 50 }; | |
| 51 | |
| 52 // TryConfigure issues a reconfiguration request. Old configuration must be | |
| 53 // considered to be the valid configuration until OnBitstreamConfigChanged | |
| 54 // callback has been issued with value signalling successful change. | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
Please rewrite this comment.
Ville-Mikko Rautio
2013/03/19 16:45:43
Done.
| |
| 55 virtual void TryConfigure( | |
| 56 const RuntimeVideoEncodingParameters& params) = 0; | |
| 57 | |
| 58 // RequestSpecialFrame allows the client to request special frames from the | |
| 59 // encoded video bitstream. The effect of the request is only visible in the | |
| 60 // bitstream buffers passed to client through the OnBitstreamReady callback. | |
| 61 // This request is served on best-effort basis and client is not given any | |
| 62 // guarantees of the realization or timing of the request. Flags parameters | |
| 63 // will be interpreted in format specific manner using enumerations. | |
| 64 virtual void RequestSpecialFrame(int flags) = 0; | |
| 65 | |
| 66 protected: | |
| 67 virtual ~EncodedVideoBitstream() {}; | |
| 68 friend class base::RefCountedThreadSafe<EncodedVideoBitstream>; | |
| 69 }; | |
| 70 | |
| 71 // Interface to represent any encoded video source. EncodedVideoSource tries | |
| 72 // to capture the essentials of what a client of an encoder would expect from | |
| 73 // the *output video bitstream*. Therefore EncodedVideoSource does not specify | |
| 74 // where the input pictures come from or how the lifetime of the device is | |
| 75 // managed. Interface is primarily focused around the concept of bitstream, | |
| 76 // discovery the configuration space of such bitstreams from device with video | |
| 77 // encoding capability, mechanisms to instantiate such a bitstream, manipulation | |
| 78 // of the bitstream properties, reception of interesting bitstream events and | |
| 79 // reception of the stream of buffers in the bitstream. | |
| 80 // | |
| 81 // Anything that provides encoded video bitstream to clients can be an | |
| 82 // EncodedVideoSource. Typical examples of this can be video encoder (duh!) and | |
| 83 // webcam that has encoding capability. In case of video encoder implementation | |
| 84 // would inherit this interface and add at least instantiatiation and | |
| 85 // destruction functionality for the encoder instance and some mechanism to feed | |
| 86 // the input to it. In case of webcam implementation would again inherit this | |
| 87 // same interface and add mechanisms to instantiate and close the webcam, but it | |
| 88 // would not have to have a mechanism to feed the input since it has internal | |
| 89 // video source. | |
| 90 class MEDIA_EXPORT EncodedVideoSource { | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
This is conceptually the entry point to this file,
Ville-Mikko Rautio
2013/03/19 16:45:43
I considered this earlier. Problem with that is in
| |
| 91 public: | |
| 92 virtual ~EncodedVideoSource() {}; | |
| 93 | |
| 94 // GetCapabilities allows the discovery of the limitations encoded video | |
| 95 // bitstreams from this source have. | |
| 96 virtual VideoEncodingLimits GetLimits() = 0; | |
| 97 | |
| 98 // OpenBitstream returns object for the stream being added. Client must | |
| 99 // consider the returned stream valid until OnBitstreamRemoved callback is | |
| 100 // called with the id. Client should check the parameters agains limits | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
typo: agains
Ville-Mikko Rautio
2013/03/19 16:45:43
Done.
| |
| 101 // reported by GetCapabilities before trying to issue an request to add an | |
|
Ami GONE FROM CHROMIUM
2013/03/18 22:53:45
s/an request/a request/
Ville-Mikko Rautio
2013/03/19 16:45:43
Done.
| |
| 102 // encoded bitstream. Returned EncodedVideoBitstream is only a proxy handle | |
| 103 // to the actual bitstream object. | |
| 104 virtual scoped_refptr<EncodedVideoBitstream> OpenBitstream( | |
| 105 EncodedVideoBitstream::Client* client, | |
| 106 const VideoEncodingParameters& params) = 0; | |
| 107 }; | |
| 108 | |
| 109 } // namespace media | |
| 110 | |
| 111 #endif // MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_ | |
| 112 | |
| OLD | NEW |