OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
3 * | |
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 | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #include <memory> | |
12 | |
13 #include "webrtc/modules/video_coding/test/receiver_tests.h" | |
14 #include "webrtc/modules/video_coding/test/vcm_payload_sink_factory.h" | |
15 #include "webrtc/system_wrappers/include/trace.h" | |
16 #include "webrtc/test/testsupport/fileutils.h" | |
17 | |
18 namespace { | |
19 | |
20 const bool kConfigProtectionEnabled = true; | |
21 const webrtc::VCMVideoProtection kConfigProtectionMethod = | |
22 webrtc::kProtectionNack; | |
23 const float kConfigLossRate = 0.0f; | |
24 const bool kConfigReordering = false; | |
25 const int64_t kConfigRttMs = 0; | |
26 const uint32_t kConfigRenderDelayMs = 0; | |
27 const uint32_t kConfigMinPlayoutDelayMs = 0; | |
28 const int64_t kConfigMaxRuntimeMs = -1; | |
29 const uint8_t kDefaultUlpFecPayloadType = 97; | |
30 const uint8_t kDefaultRedPayloadType = 96; | |
31 const uint8_t kDefaultVp8PayloadType = 100; | |
32 } // namespace | |
33 | |
34 int RtpPlay(const CmdArgs& args) { | |
35 std::string trace_file = webrtc::test::OutputPath() + "receiverTestTrace.txt"; | |
36 webrtc::Trace::CreateTrace(); | |
37 webrtc::Trace::SetTraceFile(trace_file.c_str()); | |
38 webrtc::Trace::set_level_filter(webrtc::kTraceAll); | |
39 | |
40 webrtc::rtpplayer::PayloadTypes payload_types; | |
41 payload_types.push_back(webrtc::rtpplayer::PayloadCodecTuple( | |
42 kDefaultUlpFecPayloadType, "ULPFEC", webrtc::kVideoCodecULPFEC)); | |
43 payload_types.push_back(webrtc::rtpplayer::PayloadCodecTuple( | |
44 kDefaultRedPayloadType, "RED", webrtc::kVideoCodecRED)); | |
45 payload_types.push_back(webrtc::rtpplayer::PayloadCodecTuple( | |
46 kDefaultVp8PayloadType, "VP8", webrtc::kVideoCodecVP8)); | |
47 | |
48 std::string output_file = args.outputFile; | |
49 if (output_file.empty()) | |
50 output_file = webrtc::test::OutputPath() + "RtpPlay_decoded.yuv"; | |
51 | |
52 webrtc::SimulatedClock clock(0); | |
53 webrtc::rtpplayer::VcmPayloadSinkFactory factory( | |
54 output_file, &clock, kConfigProtectionEnabled, kConfigProtectionMethod, | |
55 kConfigRttMs, kConfigRenderDelayMs, kConfigMinPlayoutDelayMs); | |
56 std::unique_ptr<webrtc::rtpplayer::RtpPlayerInterface> rtp_player( | |
57 webrtc::rtpplayer::Create(args.inputFile, &factory, &clock, payload_types, | |
58 kConfigLossRate, kConfigRttMs, | |
59 kConfigReordering)); | |
60 if (rtp_player.get() == NULL) { | |
61 return -1; | |
62 } | |
63 | |
64 int ret = 0; | |
65 while ((ret = rtp_player->NextPacket(clock.TimeInMilliseconds())) == 0) { | |
66 ret = factory.DecodeAndProcessAll(true); | |
67 if (ret < 0 || (kConfigMaxRuntimeMs > -1 && | |
68 clock.TimeInMilliseconds() >= kConfigMaxRuntimeMs)) { | |
69 break; | |
70 } | |
71 clock.AdvanceTimeMilliseconds(1); | |
72 } | |
73 | |
74 rtp_player->Print(); | |
75 | |
76 switch (ret) { | |
77 case 1: | |
78 printf("Success\n"); | |
79 return 0; | |
80 case -1: | |
81 printf("Failed\n"); | |
82 return -1; | |
83 case 0: | |
84 printf("Timeout\n"); | |
85 return -1; | |
86 } | |
87 | |
88 webrtc::Trace::ReturnTrace(); | |
89 return 0; | |
90 } | |
OLD | NEW |