Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: media/video/encoded_video_source.h

Issue 12379011: Interfaces for encoded video sources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: style nit Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 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.
19 //
20 // Client can close the bitstream simply by discarding the scoped_refptr to the
21 // object. Also, if client receives OnDestroyed 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 // Status codes to inform the client about the reasons for bitstream
27 // destruction.
28 enum StatusCode {
Ami GONE FROM CHROMIUM 2013/03/19 18:01:49 this name is unfortunately general. DestructionRea
vmr 2013/03/20 12:09:14 SGTM. Done.
29 kRemovedOnRequest = 0, // Bitstream was removed on client's request.
30 kEndOfStream, // End of stream triggered from source.
31 kInvalidConfiguration, // Client tried to initialize the bitstream with
32 // unsupported or invalid configuration.
33 kSourceRemoved, // Unexpected removal of source device, e.g. removal of
34 // webcam from USB connector.
35 kHardwareError, // Hardware has encountered internal error.
36 };
37
38 class MEDIA_EXPORT Client {
39 public:
40 // OnStreaming callback lets the client know that the bitstream has been
41 // successfully created and is streaming. Parameter modifiable lets the
Ami GONE FROM CHROMIUM 2013/03/19 18:01:49 s/modifiable/is_mutable/
vmr 2013/03/20 12:09:14 Done.
42 // client know, whether it is allowed to change the runtime configuration of
Ami GONE FROM CHROMIUM 2013/03/19 18:01:49 s/,//
vmr 2013/03/20 12:09:14 Done.
43 // the bitstream.
Ami GONE FROM CHROMIUM 2013/03/19 18:01:49 If two clients A & B open the same stream, and A g
vmr 2013/03/20 12:09:14 It's a corner case and could be handled just by re
44 virtual void OnStreaming(
Ami GONE FROM CHROMIUM 2013/03/19 18:01:49 I don't see this here (but it is present in the me
vmr 2013/03/20 12:09:14 Done.
45 scoped_refptr<EncodedVideoBitstream> bitstream, bool is_mutable) = 0;
46
47 // OnDestroyed tells the client to stop using the bitstream object and
48 // expecting bitstream buffers for the given stream. OnDestroyed will be
49 // called also in case of any unrecoverable failure in the device. After
50 // OnDestroyed is called for a bitstream it is guaranteed that that there
51 // will be no longer pending calls coming in to the client.
52 virtual void OnDestroyed(scoped_refptr<EncodedVideoBitstream> bitstream,
53 StatusCode status) = 0;
54
55 // OnBufferReady delivers the captured bitstream buffer by buffer to the
56 // client.
57 virtual void OnBufferReady(
58 scoped_refptr<EncodedVideoBitstream> bitstream,
59 scoped_refptr<const EncodedBitstreamBuffer> buffer) = 0;
60
61 // OnConfigChanged informs about change in bitstream parameters that can
62 // change during runtime.
63 virtual void OnConfigChanged(
64 scoped_refptr<EncodedVideoBitstream> bitstream,
65 const RuntimeVideoEncodingParameters& params) = 0;
66 };
67
68 // Client can request change in runtime configuration by calling TryConfigure
69 // on a bitstream. Until OnConfigChanged callback is called the old
70 // configuration is valid and there may be incoming buffers with the old
71 // configuration. Regardless of whether this call succeeded or not,
72 // OnConfigChanged callback will be issued with the current parameters.
73 virtual void TryConfigure(
74 const RuntimeVideoEncodingParameters& params) = 0;
75
76 // RequestSpecialFrame allows the client to request special frames from the
77 // encoded video bitstream. The effect of the request is only visible in the
78 // bitstream buffers passed to client through the OnBitstreamReady callback.
79 // This request is served on best-effort basis and client is not given any
80 // guarantees of the realization or timing of the request. Flags parameters
81 // will be interpreted in format specific manner using enumerations.
82 virtual void RequestSpecialFrame(int flags) = 0;
83
84 protected:
85 virtual ~EncodedVideoBitstream() {};
86 friend class base::RefCountedThreadSafe<EncodedVideoBitstream>;
87 };
88
89 // Interface to represent any encoded video source. EncodedVideoSource tries
90 // to capture the essentials of what a client of an encoder would expect from
91 // the *output video bitstream*. Therefore EncodedVideoSource does not specify
92 // where the input pictures come from or how the lifetime of the device is
93 // managed. Interface is primarily focused around the concept of bitstream,
94 // discovery the configuration space of such bitstreams from device with video
95 // encoding capability, mechanisms to instantiate such a bitstream, manipulation
96 // of the bitstream properties, reception of interesting bitstream events and
97 // reception of the stream of buffers in the bitstream.
98 //
99 // Anything that provides encoded video bitstream to clients can be an
100 // EncodedVideoSource. Typical examples of this can be video encoder (duh!) and
101 // webcam that has encoding capability. In case of video encoder implementation
102 // would inherit this interface and add at least instantiatiation and
103 // destruction functionality for the encoder instance and some mechanism to feed
104 // the input to it. In case of webcam implementation would again inherit this
105 // same interface and add mechanisms to instantiate and close the webcam, but it
106 // would not have to have a mechanism to feed the input since it has internal
107 // video source.
108 class MEDIA_EXPORT EncodedVideoSource {
109 public:
110 virtual ~EncodedVideoSource() {};
111
112 // GetCapabilities allows the discovery of the limitations encoded video
113 // bitstreams from this source have.
114 virtual VideoEncodingLimits GetLimits() = 0;
115
116 // OpenBitstream returns object for the stream being added. Client must
117 // consider the returned stream valid until OnBitstreamRemoved callback is
118 // called with the id. Client should check the parameters against limits
119 // reported by GetCapabilities before trying to issue a request to add an
120 // encoded bitstream. Returned EncodedVideoBitstream is only a proxy handle
121 // to the actual bitstream object.
122 virtual scoped_refptr<EncodedVideoBitstream> OpenBitstream(
123 EncodedVideoBitstream::Client* client,
124 const VideoEncodingParameters& params) = 0;
125 };
126
127 } // namespace media
128
129 #endif // MEDIA_VIDEO_ENCODED_VIDEO_SOURCE_H_
130
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698