OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #import <Foundation/Foundation.h> | 11 #import <Foundation/Foundation.h> |
12 #import <OCMock/OCMock.h> | 12 #import <OCMock/OCMock.h> |
13 | 13 |
14 #include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/objc_video_decoder_fact
ory.h" | 14 #include "webrtc/sdk/objc/Framework/Classes/VideoToolbox/objc_video_decoder_fact
ory.h" |
15 | 15 |
16 #import "WebRTC/RTCVideoCodec.h" | 16 #import "WebRTC/RTCVideoCodec.h" |
17 #import "WebRTC/RTCVideoCodecFactory.h" | 17 #import "WebRTC/RTCVideoCodecFactory.h" |
| 18 #include "webrtc/media/base/codec.h" |
18 #include "webrtc/modules/include/module_common_types.h" | 19 #include "webrtc/modules/include/module_common_types.h" |
19 #include "webrtc/modules/video_coding/include/video_codec_interface.h" | 20 #include "webrtc/modules/video_coding/include/video_codec_interface.h" |
20 #include "webrtc/modules/video_coding/include/video_error_codes.h" | 21 #include "webrtc/modules/video_coding/include/video_error_codes.h" |
21 #include "webrtc/rtc_base/gunit.h" | 22 #include "webrtc/rtc_base/gunit.h" |
22 | 23 |
23 id<RTCVideoDecoderFactory> CreateDecoderFactoryReturning(int return_code) { | 24 id<RTCVideoDecoderFactory> CreateDecoderFactoryReturning(int return_code) { |
24 id decoderMock = OCMProtocolMock(@protocol(RTCVideoDecoder)); | 25 id decoderMock = OCMProtocolMock(@protocol(RTCVideoDecoder)); |
25 OCMStub([decoderMock startDecodeWithSettings:[OCMArg any] numberOfCores:1]) | 26 OCMStub([decoderMock startDecodeWithSettings:[OCMArg any] numberOfCores:1]) |
26 .andReturn(return_code); | 27 .andReturn(return_code); |
27 OCMStub([decoderMock decode:[OCMArg any] | 28 OCMStub([decoderMock decode:[OCMArg any] |
(...skipping 14 matching lines...) Expand all Loading... |
42 id<RTCVideoDecoderFactory> CreateOKDecoderFactory() { | 43 id<RTCVideoDecoderFactory> CreateOKDecoderFactory() { |
43 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_OK); | 44 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_OK); |
44 } | 45 } |
45 | 46 |
46 id<RTCVideoDecoderFactory> CreateErrorDecoderFactory() { | 47 id<RTCVideoDecoderFactory> CreateErrorDecoderFactory() { |
47 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_ERROR); | 48 return CreateDecoderFactoryReturning(WEBRTC_VIDEO_CODEC_ERROR); |
48 } | 49 } |
49 | 50 |
50 webrtc::VideoDecoder *GetObjCDecoder(id<RTCVideoDecoderFactory> factory) { | 51 webrtc::VideoDecoder *GetObjCDecoder(id<RTCVideoDecoderFactory> factory) { |
51 webrtc::ObjCVideoDecoderFactory decoder_factory(factory); | 52 webrtc::ObjCVideoDecoderFactory decoder_factory(factory); |
52 return decoder_factory.CreateVideoDecoder(webrtc::kVideoCodecH264); | 53 return decoder_factory.CreateVideoDecoderWithParams(cricket::VideoCodec(cricke
t::kH264CodecName), |
| 54 {}); |
53 } | 55 } |
54 | 56 |
55 #pragma mark - | 57 #pragma mark - |
56 | 58 |
57 TEST(ObjCVideoDecoderFactoryTest, InitDecodeReturnsOKOnSuccess) { | 59 TEST(ObjCVideoDecoderFactoryTest, InitDecodeReturnsOKOnSuccess) { |
58 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory()); | 60 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory()); |
59 | 61 |
60 auto settings = new webrtc::VideoCodec(); | 62 auto settings = new webrtc::VideoCodec(); |
61 EXPECT_EQ(decoder->InitDecode(settings, 1), WEBRTC_VIDEO_CODEC_OK); | 63 EXPECT_EQ(decoder->InitDecode(settings, 1), WEBRTC_VIDEO_CODEC_OK); |
62 } | 64 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory()); | 96 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory()); |
95 | 97 |
96 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_OK); | 98 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_OK); |
97 } | 99 } |
98 | 100 |
99 TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsErrorOnFail) { | 101 TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsErrorOnFail) { |
100 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory()); | 102 webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory()); |
101 | 103 |
102 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_ERROR); | 104 EXPECT_EQ(decoder->Release(), WEBRTC_VIDEO_CODEC_ERROR); |
103 } | 105 } |
OLD | NEW |