/src/mozilla-central/media/webrtc/signaling/gtest/mediaconduit_unittests.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
2 | | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
3 | | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | | |
5 | | #include <iostream> |
6 | | #include <string> |
7 | | #include <fstream> |
8 | | #include <vector> |
9 | | #include <math.h> |
10 | | |
11 | | using namespace std; |
12 | | |
13 | | #include <MediaConduitInterface.h> |
14 | | #include <VideoConduit.h> |
15 | | #include "mozilla/UniquePtr.h" |
16 | | #include "mozilla/Unused.h" |
17 | | #include "nss.h" |
18 | | #include "runnable_utils.h" |
19 | | #include "signaling/src/common/EncodingConstraints.h" |
20 | | |
21 | | #define GTEST_HAS_RTTI 0 |
22 | | #include "gtest/gtest.h" |
23 | | |
24 | | const uint32_t SSRC = 1; |
25 | | |
26 | | //MWC RNG of George Marsaglia |
27 | | //taken from xiph.org |
28 | | static int32_t Rz, Rw; |
29 | | static inline int32_t fast_rand(void) |
30 | 0 | { |
31 | 0 | Rz=36969*(Rz&65535)+(Rz>>16); |
32 | 0 | Rw=18000*(Rw&65535)+(Rw>>16); |
33 | 0 | return (Rz<<16)+Rw; |
34 | 0 | } |
35 | | |
36 | | /** |
37 | | * A Dummy AudioConduit Tester |
38 | | * The test reads PCM samples of a standard test file and |
39 | | * passws to audio-conduit for encoding, RTPfication and |
40 | | * decoding every 10 milliseconds. |
41 | | * This decoded samples are read-off the conduit for writing |
42 | | * into output audio file in PCM format. |
43 | | */ |
44 | | class AudioSendAndReceive |
45 | | { |
46 | | public: |
47 | | static const unsigned int PLAYOUT_SAMPLE_FREQUENCY; //default is 16000 |
48 | | static const unsigned int PLAYOUT_SAMPLE_LENGTH; //default is 160 |
49 | | |
50 | | AudioSendAndReceive() |
51 | 0 | { |
52 | 0 | } |
53 | | |
54 | | ~AudioSendAndReceive() |
55 | 0 | { |
56 | 0 | } |
57 | | |
58 | | void Init(RefPtr<mozilla::AudioSessionConduit> aSession, |
59 | | RefPtr<mozilla::AudioSessionConduit> aOtherSession, |
60 | | std::string fileIn, std::string fileOut) |
61 | 0 | { |
62 | 0 |
|
63 | 0 | mSession = aSession; |
64 | 0 | mOtherSession = aOtherSession; |
65 | 0 | iFile = fileIn; |
66 | 0 | oFile = fileOut; |
67 | 0 | } |
68 | | |
69 | | //Kick start the test |
70 | | void GenerateAndReadSamples(); |
71 | | |
72 | | private: |
73 | | |
74 | | RefPtr<mozilla::AudioSessionConduit> mSession; |
75 | | RefPtr<mozilla::AudioSessionConduit> mOtherSession; |
76 | | std::string iFile; |
77 | | std::string oFile; |
78 | | |
79 | | int WriteWaveHeader(int rate, int channels, FILE* outFile); |
80 | | int FinishWaveHeader(FILE* outFile); |
81 | | void GenerateMusic(int16_t* buf, int len); |
82 | | }; |
83 | | |
84 | | const unsigned int AudioSendAndReceive::PLAYOUT_SAMPLE_FREQUENCY = 16000; |
85 | | const unsigned int AudioSendAndReceive::PLAYOUT_SAMPLE_LENGTH = 160; |
86 | | |
87 | | int AudioSendAndReceive::WriteWaveHeader(int rate, int channels, FILE* outFile) |
88 | 0 | { |
89 | 0 | //Hardcoded for 16 bit samples |
90 | 0 | unsigned char header[] = { |
91 | 0 | // File header |
92 | 0 | 0x52, 0x49, 0x46, 0x46, // 'RIFF' |
93 | 0 | 0x00, 0x00, 0x00, 0x00, // chunk size |
94 | 0 | 0x57, 0x41, 0x56, 0x45, // 'WAVE' |
95 | 0 | // fmt chunk. We always write 16-bit samples. |
96 | 0 | 0x66, 0x6d, 0x74, 0x20, // 'fmt ' |
97 | 0 | 0x10, 0x00, 0x00, 0x00, // chunk size |
98 | 0 | 0x01, 0x00, // WAVE_FORMAT_PCM |
99 | 0 | 0xFF, 0xFF, // channels |
100 | 0 | 0xFF, 0xFF, 0xFF, 0xFF, // sample rate |
101 | 0 | 0x00, 0x00, 0x00, 0x00, // data rate |
102 | 0 | 0xFF, 0xFF, // frame size in bytes |
103 | 0 | 0x10, 0x00, // bits per sample |
104 | 0 | // data chunk |
105 | 0 | 0x64, 0x61, 0x74, 0x61, // 'data' |
106 | 0 | 0xFE, 0xFF, 0xFF, 0x7F // chunk size |
107 | 0 | }; |
108 | 0 |
|
109 | 0 | #define set_uint16le(buffer, value) \ |
110 | 0 | (buffer)[0] = (value) & 0xff; \ |
111 | 0 | (buffer)[1] = (value) >> 8; |
112 | 0 | #define set_uint32le(buffer, value) \ |
113 | 0 | set_uint16le( (buffer), (value) & 0xffff ); \ |
114 | 0 | set_uint16le( (buffer) + 2, (value) >> 16 ); |
115 | 0 |
|
116 | 0 | // set dynamic header fields |
117 | 0 | set_uint16le(header + 22, channels); |
118 | 0 | set_uint32le(header + 24, rate); |
119 | 0 | set_uint16le(header + 32, channels*2); |
120 | 0 |
|
121 | 0 | size_t written = fwrite(header, 1, sizeof(header), outFile); |
122 | 0 | if (written != sizeof(header)) { |
123 | 0 | cerr << "Writing WAV header failed" << endl; |
124 | 0 | return -1; |
125 | 0 | } |
126 | 0 | |
127 | 0 | return 0; |
128 | 0 | } |
129 | | |
130 | | // Update the WAVE file header with the written length |
131 | | int AudioSendAndReceive::FinishWaveHeader(FILE* outFile) |
132 | 0 | { |
133 | 0 | // Measure how much data we've written |
134 | 0 | long end = ftell(outFile); |
135 | 0 | if (end < 16) { |
136 | 0 | cerr << "Couldn't get output file length" << endl; |
137 | 0 | return (end < 0) ? end : -1; |
138 | 0 | } |
139 | 0 |
|
140 | 0 | // Update the header |
141 | 0 | unsigned char size[4]; |
142 | 0 | int err = fseek(outFile, 40, SEEK_SET); |
143 | 0 | if (err < 0) { |
144 | 0 | cerr << "Couldn't seek to WAV file header." << endl; |
145 | 0 | return err; |
146 | 0 | } |
147 | 0 | set_uint32le(size, (end - 44) & 0xffffffff); |
148 | 0 | size_t written = fwrite(size, 1, sizeof(size), outFile); |
149 | 0 | if (written != sizeof(size)) { |
150 | 0 | cerr << "Couldn't write data size to WAV header" << endl; |
151 | 0 | return -1; |
152 | 0 | } |
153 | 0 | |
154 | 0 | // Return to the end |
155 | 0 | err = fseek(outFile, 0, SEEK_END); |
156 | 0 | if (err < 0) { |
157 | 0 | cerr << "Couldn't seek to WAV file end." << endl; |
158 | 0 | return err; |
159 | 0 | } |
160 | 0 | |
161 | 0 | return 0; |
162 | 0 | } |
163 | | |
164 | | //Code from xiph.org to generate music of predefined length |
165 | | void AudioSendAndReceive::GenerateMusic(short* buf, int len) |
166 | 0 | { |
167 | 0 | cerr <<" Generating Input Music " << endl; |
168 | 0 | int32_t a1,a2,b1,b2; |
169 | 0 | int32_t c1,c2,d1,d2; |
170 | 0 | int32_t i,j; |
171 | 0 | a1=b1=a2=b2=0; |
172 | 0 | c1=c2=d1=d2=0; |
173 | 0 | j=0; |
174 | 0 | for(i=0;i<len-1;i+=2) |
175 | 0 | { |
176 | 0 | int32_t r; |
177 | 0 | int32_t v1,v2; |
178 | 0 | v1=v2=(((j*((j>>12)^((j>>10|j>>12)&26&j>>7)))&128)+128)<<15; |
179 | 0 | r=fast_rand();v1+=r&65535;v1-=r>>16; |
180 | 0 | r=fast_rand();v2+=r&65535;v2-=r>>16; |
181 | 0 | b1=v1-a1+((b1*61+32)>>6);a1=v1; |
182 | 0 | b2=v2-a2+((b2*61+32)>>6);a2=v2; |
183 | 0 | c1=(30*(c1+b1+d1)+32)>>6;d1=b1; |
184 | 0 | c2=(30*(c2+b2+d2)+32)>>6;d2=b2; |
185 | 0 | v1=(c1+128)>>8; |
186 | 0 | v2=(c2+128)>>8; |
187 | 0 | buf[i]=v1>32767?32767:(v1<-32768?-32768:v1); |
188 | 0 | buf[i+1]=v2>32767?32767:(v2<-32768?-32768:v2); |
189 | 0 | if(i%6==0)j++; |
190 | 0 | } |
191 | 0 | cerr << "Generating Input Music Done " << endl; |
192 | 0 | } |
193 | | |
194 | | //Hardcoded for 16 bit samples for now |
195 | | void AudioSendAndReceive::GenerateAndReadSamples() |
196 | 0 | { |
197 | 0 | auto audioInput = mozilla::MakeUnique<int16_t []>(PLAYOUT_SAMPLE_LENGTH); |
198 | 0 | auto audioOutput = mozilla::MakeUnique<int16_t []>(PLAYOUT_SAMPLE_LENGTH); |
199 | 0 | short* inbuf; |
200 | 0 | int sampleLengthDecoded = 0; |
201 | 0 | unsigned int SAMPLES = (PLAYOUT_SAMPLE_FREQUENCY / 100); //10 milliseconds |
202 | 0 | int CHANNELS = 1; //mono audio |
203 | 0 | int sampleLengthInBytes = sizeof(int16_t) * PLAYOUT_SAMPLE_LENGTH; |
204 | 0 | //generated audio buffer |
205 | 0 | inbuf = (short *)moz_xmalloc(sizeof(short)*SAMPLES*CHANNELS); |
206 | 0 | memset(audioInput.get(),0,sampleLengthInBytes); |
207 | 0 | memset(audioOutput.get(),0,sampleLengthInBytes); |
208 | 0 | MOZ_ASSERT(SAMPLES <= PLAYOUT_SAMPLE_LENGTH); |
209 | 0 |
|
210 | 0 | FILE* inFile = fopen( iFile.c_str(), "wb+"); |
211 | 0 | if(!inFile) { |
212 | 0 | cerr << "Input File Creation Failed " << endl; |
213 | 0 | free(inbuf); |
214 | 0 | return; |
215 | 0 | } |
216 | 0 | |
217 | 0 | FILE* outFile = fopen( oFile.c_str(), "wb+"); |
218 | 0 | if(!outFile) { |
219 | 0 | cerr << "Output File Creation Failed " << endl; |
220 | 0 | free(inbuf); |
221 | 0 | fclose(inFile); |
222 | 0 | return; |
223 | 0 | } |
224 | 0 | |
225 | 0 | //Create input file with the music |
226 | 0 | WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, inFile); |
227 | 0 | GenerateMusic(inbuf, SAMPLES); |
228 | 0 | mozilla::Unused << fwrite(inbuf,1,SAMPLES*sizeof(inbuf[0])*CHANNELS,inFile); |
229 | 0 | FinishWaveHeader(inFile); |
230 | 0 | fclose(inFile); |
231 | 0 |
|
232 | 0 | WriteWaveHeader(PLAYOUT_SAMPLE_FREQUENCY, 1, outFile); |
233 | 0 | unsigned int numSamplesReadFromInput = 0; |
234 | 0 | do |
235 | 0 | { |
236 | 0 | if(!memcpy(audioInput.get(), inbuf, sampleLengthInBytes)) |
237 | 0 | { |
238 | 0 | free(inbuf); |
239 | 0 | fclose(outFile); |
240 | 0 | return; |
241 | 0 | } |
242 | 0 | |
243 | 0 | numSamplesReadFromInput += PLAYOUT_SAMPLE_LENGTH; |
244 | 0 |
|
245 | 0 | mSession->SendAudioFrame(audioInput.get(), |
246 | 0 | PLAYOUT_SAMPLE_LENGTH, |
247 | 0 | PLAYOUT_SAMPLE_FREQUENCY, |
248 | 0 | 1, 10); |
249 | 0 |
|
250 | 0 | PR_Sleep(PR_MillisecondsToInterval(10)); |
251 | 0 | mOtherSession->GetAudioFrame(audioOutput.get(), PLAYOUT_SAMPLE_FREQUENCY, |
252 | 0 | 10, sampleLengthDecoded); |
253 | 0 | if(sampleLengthDecoded == 0) |
254 | 0 | { |
255 | 0 | cerr << " Zero length Sample " << endl; |
256 | 0 | } |
257 | 0 |
|
258 | 0 | int wrote_ = fwrite (audioOutput.get(), 1 , sampleLengthInBytes, outFile); |
259 | 0 | if(wrote_ != sampleLengthInBytes) |
260 | 0 | { |
261 | 0 | cerr << "Couldn't Write " << sampleLengthInBytes << "bytes" << endl; |
262 | 0 | break; |
263 | 0 | } |
264 | 0 | }while(numSamplesReadFromInput < SAMPLES); |
265 | 0 |
|
266 | 0 | FinishWaveHeader(outFile); |
267 | 0 | free(inbuf); |
268 | 0 | fclose(outFile); |
269 | 0 | } |
270 | | |
271 | | |
272 | | /** |
273 | | * Webrtc Audio and Video External Transport Class |
274 | | * The functions in this class will be invoked by the conduit |
275 | | * when it has RTP/RTCP frame to transmit. |
276 | | * For everty RTP/RTCP frame we receive, we pass it back |
277 | | * to the conduit for eventual decoding and rendering. |
278 | | */ |
279 | | class WebrtcMediaTransport : public mozilla::TransportInterface |
280 | | { |
281 | | public: |
282 | | WebrtcMediaTransport():numPkts(0), |
283 | | mAudio(false), |
284 | | mVideo(false) |
285 | 0 | { |
286 | 0 | } |
287 | | |
288 | | ~WebrtcMediaTransport() |
289 | 0 | { |
290 | 0 | } |
291 | | |
292 | | virtual nsresult SendRtpPacket(const uint8_t* data, size_t len) |
293 | 0 | { |
294 | 0 | ++numPkts; |
295 | 0 |
|
296 | 0 | if(mAudio) |
297 | 0 | { |
298 | 0 | mOtherAudioSession->ReceivedRTPPacket(data,len,SSRC); |
299 | 0 | } else |
300 | 0 | { |
301 | 0 | mOtherVideoSession->ReceivedRTPPacket(data,len,SSRC); |
302 | 0 | } |
303 | 0 | return NS_OK; |
304 | 0 | } |
305 | | |
306 | | virtual nsresult SendRtcpPacket(const uint8_t* data, size_t len) |
307 | 0 | { |
308 | 0 | if(mAudio) |
309 | 0 | { |
310 | 0 | mOtherAudioSession->ReceivedRTCPPacket(data,len); |
311 | 0 | } else |
312 | 0 | { |
313 | 0 | mOtherVideoSession->ReceivedRTCPPacket(data,len); |
314 | 0 | } |
315 | 0 | return NS_OK; |
316 | 0 | } |
317 | | |
318 | | //Treat this object as Audio Transport |
319 | | void SetAudioSession(RefPtr<mozilla::AudioSessionConduit> aSession, |
320 | | RefPtr<mozilla::AudioSessionConduit> |
321 | | aOtherSession) |
322 | 0 | { |
323 | 0 | mAudioSession = aSession; |
324 | 0 | mOtherAudioSession = aOtherSession; |
325 | 0 | mAudio = true; |
326 | 0 | } |
327 | | |
328 | | // Treat this object as Video Transport |
329 | | void SetVideoSession(RefPtr<mozilla::VideoSessionConduit> aSession, |
330 | | RefPtr<mozilla::VideoSessionConduit> |
331 | | aOtherSession) |
332 | 0 | { |
333 | 0 | mVideoSession = aSession; |
334 | 0 | mOtherVideoSession = aOtherSession; |
335 | 0 | mVideo = true; |
336 | 0 | } |
337 | | |
338 | | private: |
339 | | RefPtr<mozilla::AudioSessionConduit> mAudioSession; |
340 | | RefPtr<mozilla::VideoSessionConduit> mVideoSession; |
341 | | RefPtr<mozilla::VideoSessionConduit> mOtherVideoSession; |
342 | | RefPtr<mozilla::AudioSessionConduit> mOtherAudioSession; |
343 | | int numPkts; |
344 | | bool mAudio, mVideo; |
345 | | }; |
346 | | |
347 | | using namespace mozilla; |
348 | | |
349 | | namespace test { |
350 | | |
351 | | class TransportConduitTest : public ::testing::Test |
352 | | { |
353 | | public: |
354 | | |
355 | | TransportConduitTest() |
356 | 0 | { |
357 | 0 | //input and output file names |
358 | 0 | iAudiofilename = "input.wav"; |
359 | 0 | oAudiofilename = "recorded.wav"; |
360 | 0 |
|
361 | 0 | NSS_NoDB_Init(nullptr); |
362 | 0 | } |
363 | | |
364 | | ~TransportConduitTest() |
365 | 0 | { |
366 | 0 | mAudioSession = nullptr; |
367 | 0 | mAudioSession2 = nullptr; |
368 | 0 | mAudioTransport = nullptr; |
369 | 0 |
|
370 | 0 | mVideoSession = nullptr; |
371 | 0 | mVideoSession2 = nullptr; |
372 | 0 | mVideoRenderer = nullptr; |
373 | 0 | mVideoTransport = nullptr; |
374 | 0 | } |
375 | | |
376 | | //1. Dump audio samples to dummy external transport |
377 | | void TestDummyAudioAndTransport() |
378 | 0 | { |
379 | 0 | //get pointer to AudioSessionConduit |
380 | 0 | int err=0; |
381 | 0 | mAudioSession = mozilla::AudioSessionConduit::Create(); |
382 | 0 | if( !mAudioSession ) { |
383 | 0 | ASSERT_NE(mAudioSession, (void*)nullptr); |
384 | 0 | } |
385 | 0 |
|
386 | 0 | mAudioSession2 = mozilla::AudioSessionConduit::Create(); |
387 | 0 | if( !mAudioSession2 ) { |
388 | 0 | ASSERT_NE(mAudioSession2, (void*)nullptr); |
389 | 0 | } |
390 | 0 |
|
391 | 0 | WebrtcMediaTransport* xport = new WebrtcMediaTransport(); |
392 | 0 | ASSERT_NE(xport, (void*)nullptr); |
393 | 0 | xport->SetAudioSession(mAudioSession, mAudioSession2); |
394 | 0 | mAudioTransport = xport; |
395 | 0 |
|
396 | 0 | // attach the transport to audio-conduit |
397 | 0 | err = mAudioSession->SetTransmitterTransport(mAudioTransport); |
398 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
399 | 0 | err = mAudioSession2->SetReceiverTransport(mAudioTransport); |
400 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
401 | 0 |
|
402 | 0 | //configure send and recv codecs on the audio-conduit |
403 | 0 | //mozilla::AudioCodecConfig cinst1(124, "PCMU", 8000, 80, 1, 64000, false); |
404 | 0 | mozilla::AudioCodecConfig cinst1(124, "opus", 48000, 960, 1, 64000, false); |
405 | 0 | mozilla::AudioCodecConfig cinst2(125, "L16", 16000, 320, 1, 256000, false); |
406 | 0 |
|
407 | 0 | std::vector<mozilla::AudioCodecConfig*> rcvCodecList; |
408 | 0 | rcvCodecList.push_back(&cinst1); |
409 | 0 | rcvCodecList.push_back(&cinst2); |
410 | 0 |
|
411 | 0 | err = mAudioSession->ConfigureSendMediaCodec(&cinst1); |
412 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
413 | 0 | err = mAudioSession->StartTransmitting(); |
414 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
415 | 0 | err = mAudioSession->ConfigureRecvMediaCodecs(rcvCodecList); |
416 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
417 | 0 |
|
418 | 0 | err = mAudioSession2->ConfigureSendMediaCodec(&cinst1); |
419 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
420 | 0 | err = mAudioSession2->StartTransmitting(); |
421 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
422 | 0 | err = mAudioSession2->ConfigureRecvMediaCodecs(rcvCodecList); |
423 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
424 | 0 |
|
425 | 0 | //start generating samples |
426 | 0 | audioTester.Init(mAudioSession,mAudioSession2, iAudiofilename,oAudiofilename); |
427 | 0 | cerr << " ******************************************************** " << endl; |
428 | 0 | cerr << " Generating Audio Samples " << endl; |
429 | 0 | cerr << " ******************************************************** " << endl; |
430 | 0 | audioTester.GenerateAndReadSamples(); |
431 | 0 | cerr << " ******************************************************** " << endl; |
432 | 0 | cerr << " Input Audio File " << iAudiofilename << endl; |
433 | 0 | cerr << " Output Audio File " << oAudiofilename << endl; |
434 | 0 | cerr << " ******************************************************** " << endl; |
435 | 0 | } |
436 | | |
437 | | void TestVideoConduitCodecAPI() |
438 | 0 | { |
439 | 0 | int err = 0; |
440 | 0 | RefPtr<mozilla::VideoSessionConduit> videoSession; |
441 | 0 | //get pointer to VideoSessionConduit |
442 | 0 | videoSession = VideoSessionConduit::Create( |
443 | 0 | WebRtcCallWrapper::Create(), GetCurrentThreadEventTarget()); |
444 | 0 | if( !videoSession ) { |
445 | 0 | ASSERT_NE(videoSession, (void*)nullptr); |
446 | 0 | } |
447 | 0 |
|
448 | 0 | std::vector<unsigned int> ssrcs = {SSRC}; |
449 | 0 | videoSession->SetLocalSSRCs(ssrcs); |
450 | 0 |
|
451 | 0 | //Test Configure Recv Codec APIS |
452 | 0 | cerr << " *************************************************" << endl; |
453 | 0 | cerr << " Test Receive Codec Configuration API Now " << endl; |
454 | 0 | cerr << " *************************************************" << endl; |
455 | 0 |
|
456 | 0 | std::vector<mozilla::VideoCodecConfig* > rcvCodecList; |
457 | 0 |
|
458 | 0 | //Same APIs |
459 | 0 | mozilla::EncodingConstraints constraints; |
460 | 0 | mozilla::VideoCodecConfig cinst1(120, "VP8", constraints); |
461 | 0 | VideoCodecConfig::SimulcastEncoding encoding; |
462 | 0 | cinst1.mSimulcastEncodings.push_back(encoding); |
463 | 0 |
|
464 | 0 | // This test is disabled because with the current code this will trigger an |
465 | 0 | // assertion in video_receive_stream.cc because we this results in a |
466 | 0 | // duplicate payload type for different encoders. |
467 | 0 | /* |
468 | 0 | cerr << " *************************************************" << endl; |
469 | 0 | cerr << " 1. Same Codec (VP8) Repeated Twice " << endl; |
470 | 0 | cerr << " *************************************************" << endl; |
471 | 0 |
|
472 | 0 | mozilla::VideoCodecConfig cinst2(120, "VP8", constraints); |
473 | 0 | cinst2.mSimulcastEncodings.push_back(encoding); |
474 | 0 | rcvCodecList.push_back(&cinst1); |
475 | 0 | rcvCodecList.push_back(&cinst2); |
476 | 0 | err = videoSession->ConfigureRecvMediaCodecs(rcvCodecList); |
477 | 0 | EXPECT_EQ(err, mozilla::kMediaConduitNoError); |
478 | 0 | rcvCodecList.pop_back(); |
479 | 0 | rcvCodecList.pop_back(); |
480 | 0 | */ |
481 | 0 |
|
482 | 0 | cerr << " *************************************************" << endl; |
483 | 0 | cerr << " 2. Codec With Invalid Payload Names " << endl; |
484 | 0 | cerr << " *************************************************" << endl; |
485 | 0 | cerr << " Setting payload 1 with name: I4201234tttttthhhyyyy89087987y76t567r7756765rr6u6676" << endl; |
486 | 0 | cerr << " Setting payload 2 with name of zero length" << endl; |
487 | 0 |
|
488 | 0 | mozilla::VideoCodecConfig cinst3(124, "I4201234tttttthhhyyyy89087987y76t567r7756765rr6u6676", constraints); |
489 | 0 | cinst3.mSimulcastEncodings.push_back(encoding); |
490 | 0 | mozilla::VideoCodecConfig cinst4(124, "", constraints); |
491 | 0 | cinst4.mSimulcastEncodings.push_back(encoding); |
492 | 0 |
|
493 | 0 | rcvCodecList.push_back(&cinst3); |
494 | 0 | rcvCodecList.push_back(&cinst4); |
495 | 0 |
|
496 | 0 | err = videoSession->ConfigureRecvMediaCodecs(rcvCodecList); |
497 | 0 | EXPECT_TRUE(err != mozilla::kMediaConduitNoError); |
498 | 0 | rcvCodecList.pop_back(); |
499 | 0 | rcvCodecList.pop_back(); |
500 | 0 |
|
501 | 0 |
|
502 | 0 | cerr << " *************************************************" << endl; |
503 | 0 | cerr << " 3. Null Codec Parameter " << endl; |
504 | 0 | cerr << " *************************************************" << endl; |
505 | 0 |
|
506 | 0 | rcvCodecList.push_back(nullptr); |
507 | 0 |
|
508 | 0 | err = videoSession->ConfigureRecvMediaCodecs(rcvCodecList); |
509 | 0 | EXPECT_TRUE(err != mozilla::kMediaConduitNoError); |
510 | 0 | rcvCodecList.pop_back(); |
511 | 0 |
|
512 | 0 | cerr << " *************************************************" << endl; |
513 | 0 | cerr << " Test Send Codec Configuration API Now " << endl; |
514 | 0 | cerr << " *************************************************" << endl; |
515 | 0 |
|
516 | 0 | cerr << " *************************************************" << endl; |
517 | 0 | cerr << " 1. Same Codec (VP8) Repeated Twice " << endl; |
518 | 0 | cerr << " *************************************************" << endl; |
519 | 0 |
|
520 | 0 | err = videoSession->ConfigureSendMediaCodec(&cinst1); |
521 | 0 | EXPECT_EQ(mozilla::kMediaConduitNoError, err); |
522 | 0 | err = videoSession->StartTransmitting(); |
523 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
524 | 0 | err = videoSession->ConfigureSendMediaCodec(&cinst1); |
525 | 0 | EXPECT_EQ(mozilla::kMediaConduitNoError, err); |
526 | 0 | err = videoSession->StartTransmitting(); |
527 | 0 | ASSERT_EQ(mozilla::kMediaConduitNoError, err); |
528 | 0 |
|
529 | 0 |
|
530 | 0 | cerr << " *************************************************" << endl; |
531 | 0 | cerr << " 2. Codec With Invalid Payload Names " << endl; |
532 | 0 | cerr << " *************************************************" << endl; |
533 | 0 | cerr << " Setting payload with name: I4201234tttttthhhyyyy89087987y76t567r7756765rr6u6676" << endl; |
534 | 0 |
|
535 | 0 | err = videoSession->ConfigureSendMediaCodec(&cinst3); |
536 | 0 | EXPECT_TRUE(err != mozilla::kMediaConduitNoError); |
537 | 0 |
|
538 | 0 | cerr << " *************************************************" << endl; |
539 | 0 | cerr << " 3. Null Codec Parameter " << endl; |
540 | 0 | cerr << " *************************************************" << endl; |
541 | 0 |
|
542 | 0 | err = videoSession->ConfigureSendMediaCodec(nullptr); |
543 | 0 | EXPECT_TRUE(err != mozilla::kMediaConduitNoError); |
544 | 0 |
|
545 | 0 | videoSession->DeleteStreams(); |
546 | 0 | } |
547 | | |
548 | | private: |
549 | | //Audio Conduit Test Objects |
550 | | RefPtr<mozilla::AudioSessionConduit> mAudioSession; |
551 | | RefPtr<mozilla::AudioSessionConduit> mAudioSession2; |
552 | | RefPtr<mozilla::TransportInterface> mAudioTransport; |
553 | | AudioSendAndReceive audioTester; |
554 | | |
555 | | //Video Conduit Test Objects |
556 | | RefPtr<mozilla::VideoSessionConduit> mVideoSession; |
557 | | RefPtr<mozilla::VideoSessionConduit> mVideoSession2; |
558 | | RefPtr<mozilla::VideoRenderer> mVideoRenderer; |
559 | | RefPtr<mozilla::TransportInterface> mVideoTransport; |
560 | | |
561 | | std::string fileToPlay; |
562 | | std::string fileToRecord; |
563 | | std::string iAudiofilename; |
564 | | std::string oAudiofilename; |
565 | | }; |
566 | | |
567 | | |
568 | | // Disabled, see Bug 1319121 |
569 | 0 | TEST_F(TransportConduitTest, DISABLED_TestDummyAudioWithTransport) { |
570 | 0 | TestDummyAudioAndTransport(); |
571 | 0 | } |
572 | | |
573 | 0 | TEST_F(TransportConduitTest, TestVideoConduitCodecAPI) { |
574 | 0 | TestVideoConduitCodecAPI(); |
575 | 0 | } |
576 | | |
577 | | } // end namespace |