Skip to content

Commit ea67d06

Browse files
committed
completed testing/fixing for audio frame data callbacks
added code for video frame data callbacks
1 parent e4a810c commit ea67d06

File tree

76 files changed

+2805
-1022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2805
-1022
lines changed

idl/AudioBuffers.idl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ namespace org
3434
{
3535
namespace webRtc
3636
{
37-
[special]
37+
[special, disposable]
3838
interface AudioData
3939
{
4040
/// <summary>

idl/MediaStreamTrack.idl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ namespace org
3434
{
3535
namespace webRtc
3636
{
37+
/// <summary>
38+
/// The event is fired when an audio buffer is ready for processing.
39+
/// <summary>
40+
[disposable]
41+
interface VideoFrameBufferEvent
42+
{
43+
[constructor, delete, default]
44+
void VideoFrameBufferEvent();
45+
46+
/// <summary>
47+
/// Gets the video buffer for further processing.
48+
/// <summary>
49+
[getter]
50+
VideoFrameBuffer buffer;
51+
};
52+
3753
/// <summary>
3854
/// A MediaStreamTrack object represents a media source in the User Agent.
3955
/// An example source is a device connected to the User Agent. Other
@@ -129,6 +145,12 @@ namespace org
129145
[event]
130146
void onFrameRateChanged(float frameRate);
131147

148+
/// <summary>
149+
/// Fires events when an video buffer is available.
150+
/// </summary>
151+
[event]
152+
void onVideoFrame(VideoFrameBufferEvent buffer);
153+
132154
};
133155
}
134156
}

idl/VideoBuffers.idl

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
/*
2+
3+
Copyright (c) 2017, Optical Tone Ltd.
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
19+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25+
26+
The views and conclusions contained in the software and documentation are those
27+
of the authors and should not be interpreted as representing official policies,
28+
either expressed or implied, of the FreeBSD Project.
29+
30+
*/
31+
32+
33+
namespace org
34+
{
35+
namespace webRtc
36+
{
37+
[special, disposable]
38+
interface VideoData
39+
{
40+
[constructor, default, delete]
41+
void VideoData();
42+
43+
[getter]
44+
bool is8BitColorSpace;
45+
46+
[getter]
47+
bool is16BitColorSpace;
48+
49+
/// <summary>
50+
/// Gets or sets the video 8 bit color space data.
51+
/// <summary>
52+
[getter]
53+
std::list<uint8> data8bit;
54+
55+
/// <summary>
56+
/// Gets or sets the video 16 bit color space data.
57+
/// <summary>
58+
[getter]
59+
std::list<uint16> data16bit;
60+
};
61+
62+
[disposable]
63+
interface VideoFrameBuffer
64+
{
65+
[constructor, default, delete]
66+
void VideoFrameBuffer();
67+
68+
/// <summary>
69+
/// Gets the video frame type.
70+
/// </summary>
71+
[getter]
72+
VideoFrameBufferType type;
73+
74+
/// <summary>
75+
/// Gets the width of the video frame.
76+
/// <summary>
77+
[getter]
78+
int width;
79+
80+
/// <summary>
81+
/// Gets the width of the video frame.
82+
/// <summary>
83+
[getter]
84+
int height;
85+
86+
/// <summary>
87+
/// Convert to a new (or return an existing) I420 frame buffer (if possible).
88+
/// <summary>
89+
VideoFramePlanarYuvBuffer toI420();
90+
91+
/// <summary>
92+
/// Gets the YUV frame if the buffer type is YUV format.
93+
/// <summary>
94+
[getter]
95+
VideoFramePlanarYuvBuffer yuvFrame;
96+
97+
/// <summary>
98+
/// Gets the I420A frame if the buffer type is YUVA.
99+
/// <summary>
100+
[getter]
101+
VideoFramePlanarYuvaBuffer yuvaFrame;
102+
103+
/// <summary>
104+
/// Gets a native frame if the buffer type is native.
105+
/// <summary>
106+
[getter]
107+
VideoFrameNativeBuffer nativeFrame;
108+
};
109+
110+
interface VideoFramePlanarYuvBuffer : VideoFrameBuffer
111+
{
112+
[constructor, default, delete]
113+
void VideoFramePlanarYuvBuffer();
114+
115+
/// <summary>
116+
/// Gets the chroma width of the video frame.
117+
/// <summary>
118+
[getter]
119+
int chromaWidth;
120+
121+
/// <summary>
122+
/// Gets the chroma width of the video frame.
123+
/// <summary>
124+
[getter]
125+
int chromaHeight;
126+
127+
/// <summary>
128+
/// Gets the number of Y steps (in terms of VideoData) between
129+
/// successive rows for the given plane.
130+
/// <summary>
131+
[getter]
132+
int strideY;
133+
134+
/// <summary>
135+
/// Gets the number of U steps (in terms of VideoData) between
136+
/// successive rows for the given plane.
137+
/// <summary>
138+
[getter]
139+
int strideU;
140+
141+
/// <summary>
142+
/// Gets the number of V steps (in terms of VideoData) between
143+
/// successive rows for the given plane.
144+
/// <summary>
145+
[getter]
146+
int strideV;
147+
148+
[getter]
149+
VideoData y;
150+
151+
[getter]
152+
VideoData u;
153+
154+
[getter]
155+
VideoData v;
156+
};
157+
158+
interface VideoFramePlanarYuvaBuffer : VideoFramePlanarYuvBuffer
159+
{
160+
[constructor, default, delete]
161+
void VideoFramePlanarYuvaBuffer();
162+
163+
/// <summary>
164+
/// Gets the number of A steps (in terms of VideoData) between
165+
/// successive rows for the given plane.
166+
/// <summary>
167+
[getter]
168+
int strideA;
169+
170+
[getter]
171+
VideoData a;
172+
};
173+
174+
interface VideoFrameNativeBuffer : VideoFrameBuffer
175+
{
176+
[constructor, default, delete]
177+
void VideoFrameNativeBuffer();
178+
179+
/// <summary>
180+
/// Gets the native sample from the video frame.
181+
/// <summary>
182+
[getter]
183+
MediaSample sample;
184+
185+
};
186+
}
187+
}

idl/VideoCapturer.idl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,10 @@ namespace org
208208
VideoCaptureState state;
209209

210210
/// <summary>
211-
/// Event indicates new captured sample available.
211+
/// Event fires when a new video frame buffer is available.
212212
/// </summary>
213213
[event]
214-
void onVideoSampleReceived(MediaSample sample);
214+
void onVideoFrame(VideoFrameBufferEvent event);
215215

216216
};
217217
}

idl/WebRtc.idl

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ namespace org
9494
interface RTCCertificate;
9595
interface RTCKeyParams;
9696
interface VideoCapturer;
97+
interface VideoData;
9798
interface WebRtcFactory;
99+
interface VideoFrameBuffer;
100+
interface VideoFrameBufferEvent;
101+
interface VideoFramePlanarYuvBuffer;
102+
interface VideoFramePlanarYuvaBuffer;
103+
interface VideoFrameNativeBuffer;
98104

99105
typedef zs::PromiseRejectionReason<RTCError> PromiseWithRejectionRTCError;
100106
typedef zs::PromiseWith<RTCSessionDescription> PromiseWithDescription;
@@ -144,7 +150,6 @@ namespace org
144150
/// <summary>
145151
/// A message queue for receiving delegate events.
146152
/// </summary>
147-
[special]
148153
interface EventQueue
149154
{
150155
/// <summary>
@@ -153,12 +158,6 @@ namespace org
153158
[constructor, delete]
154159
void EventQueue();
155160

156-
/// <summary>
157-
/// Constructs an event queue object from a native queue type.
158-
/// </summary>
159-
[constructor, default, altname(EventQueueWithNativeQueue)]
160-
void EventQueue(Any queue);
161-
162161
/// <summary>
163162
/// Gets or creates an event queue by queue name. If the queue is not
164163
/// found then a new thread queue will be created.
@@ -181,12 +180,6 @@ namespace org
181180
/// </summary>
182181
[static]
183182
EventQueue getDefaultForUi();
184-
185-
/// <summary>
186-
/// Gets a native queue from an event queue object.
187-
/// </summary>
188-
[getter]
189-
Any queue;
190183
};
191184

192185
[special, static, platform(webhidden)]
@@ -214,10 +207,16 @@ namespace org
214207
EventQueue queue;
215208

216209
/// <summary>
217-
/// Gets or sets the default queue for processing audio frame events.
218-
/// If not specified then the GUI queue is used.
210+
/// Gets or sets the default queue for processing audio capture frame
211+
/// events. If not specified then the GUI queue is used.
212+
/// </summary>
213+
EventQueue audioCaptureFrameProcessingQueue;
214+
215+
/// <summary>
216+
/// Gets or sets the default queue for processing audio render frame
217+
/// events. If not specified then the GUI queue is used.
219218
/// </summary>
220-
EventQueue audioFrameProcessingQueue;
219+
EventQueue audioRenderFrameProcessingQueue;
221220

222221
/// <summary>
223222
/// Gets or sets the default queue for processing video frame

idl/WebRtcFactory.idl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,20 @@ namespace org
100100
{
101101

102102
/// <summary>
103-
/// Gets or sets if audio capturing is be enabled.
103+
/// Gets or sets if audio capturing is enabled.
104104
/// </summary>
105105
bool audioCapturingEnabled = true;
106106

107107
/// <summary>
108108
/// Gets or sets if audio rendering is enabled.
109109
/// </summary>
110110
bool audioRenderingEnabled = true;
111+
112+
/// <summary>
113+
/// Gets or sets if audio post-capture and pre-render events should be
114+
/// enabled.
115+
/// </summary>
116+
bool enableAudioBufferEvents = false;
111117
};
112118

113119
/// <summary>

idl/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"SessionDescription.idl",
5252
"PeerConnection.idl",
5353
"AudioBuffers.idl",
54+
"VideoBuffers.idl",
5455
"WebRtcFactory.idl",
5556
]
5657
}

idl/enums.idl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,15 @@ namespace org
950950
CustomRenderProcessingRuntimeSetting
951951
};
952952

953+
enum VideoFrameBufferType
954+
{
955+
Native,
956+
I420,
957+
I420A,
958+
I444,
959+
I010
960+
};
961+
953962
}
954963
}
955964

windows/wrapper/impl_org_webRtc_AudioBuffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ wrapper::org::webRtc::AudioDataPtr wrapper::impl::org::webRtc::AudioBuffer::chan
8484
ZS_ASSERT(native_);
8585
if (!native_)
8686
return {};
87-
return UseAudioData::toWrapper(native_->channels()[channel], native_->num_channels());
87+
return UseAudioData::toWrapper(native_->channels()[channel], native_->num_frames());
8888
}
8989

9090
//------------------------------------------------------------------------------

0 commit comments

Comments
 (0)