OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webrtc/test/testsupport/fileutils.h" | 21 #include "webrtc/test/testsupport/fileutils.h" |
22 | 22 |
23 CmdArgs::CmdArgs() | 23 CmdArgs::CmdArgs() |
24 : codecName("VP8"), | 24 : codecName("VP8"), |
25 codecType(webrtc::kVideoCodecVP8), | 25 codecType(webrtc::kVideoCodecVP8), |
26 width(352), | 26 width(352), |
27 height(288), | 27 height(288), |
28 rtt(0), | 28 rtt(0), |
29 inputFile(webrtc::test::ProjectRootPath() + "/resources/foreman_cif.yuv"), | 29 inputFile(webrtc::test::ProjectRootPath() + "/resources/foreman_cif.yuv"), |
30 outputFile(webrtc::test::OutputPath() + | 30 outputFile(webrtc::test::OutputPath() + |
31 "video_coding_test_output_352x288.yuv") { | 31 "video_coding_test_output_352x288.yuv") {} |
32 } | |
33 | 32 |
34 namespace { | 33 namespace { |
35 | 34 |
36 void SplitFilename(const std::string& filename, std::string* basename, | 35 void SplitFilename(const std::string& filename, |
| 36 std::string* basename, |
37 std::string* extension) { | 37 std::string* extension) { |
38 assert(basename); | 38 assert(basename); |
39 assert(extension); | 39 assert(extension); |
40 | 40 |
41 std::string::size_type idx; | 41 std::string::size_type idx; |
42 idx = filename.rfind('.'); | 42 idx = filename.rfind('.'); |
43 | 43 |
44 if(idx != std::string::npos) { | 44 if (idx != std::string::npos) { |
45 *basename = filename.substr(0, idx); | 45 *basename = filename.substr(0, idx); |
46 *extension = filename.substr(idx + 1); | 46 *extension = filename.substr(idx + 1); |
47 } else { | 47 } else { |
48 *basename = filename; | 48 *basename = filename; |
49 *extension = ""; | 49 *extension = ""; |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 std::string AppendWidthHeightCount(const std::string& filename, int width, | 53 std::string AppendWidthHeightCount(const std::string& filename, |
54 int height, int count) { | 54 int width, |
| 55 int height, |
| 56 int count) { |
55 std::string basename; | 57 std::string basename; |
56 std::string extension; | 58 std::string extension; |
57 SplitFilename(filename, &basename, &extension); | 59 SplitFilename(filename, &basename, &extension); |
58 std::stringstream ss; | 60 std::stringstream ss; |
59 ss << basename << "_" << count << "." << width << "_" << height << "." << | 61 ss << basename << "_" << count << "." << width << "_" << height << "." |
60 extension; | 62 << extension; |
61 return ss.str(); | 63 return ss.str(); |
62 } | 64 } |
63 | 65 |
64 } // namespace | 66 } // namespace |
65 | 67 |
66 FileOutputFrameReceiver::FileOutputFrameReceiver( | 68 FileOutputFrameReceiver::FileOutputFrameReceiver( |
67 const std::string& base_out_filename, uint32_t ssrc) | 69 const std::string& base_out_filename, |
| 70 uint32_t ssrc) |
68 : out_filename_(), | 71 : out_filename_(), |
69 out_file_(NULL), | 72 out_file_(NULL), |
70 timing_file_(NULL), | 73 timing_file_(NULL), |
71 width_(0), | 74 width_(0), |
72 height_(0), | 75 height_(0), |
73 count_(0) { | 76 count_(0) { |
74 std::string basename; | 77 std::string basename; |
75 std::string extension; | 78 std::string extension; |
76 if (base_out_filename.empty()) { | 79 if (base_out_filename.empty()) { |
77 basename = webrtc::test::OutputPath() + "rtp_decoded"; | 80 basename = webrtc::test::OutputPath() + "rtp_decoded"; |
78 extension = "yuv"; | 81 extension = "yuv"; |
79 } else { | 82 } else { |
80 SplitFilename(base_out_filename, &basename, &extension); | 83 SplitFilename(base_out_filename, &basename, &extension); |
81 } | 84 } |
82 std::stringstream ss; | 85 std::stringstream ss; |
83 ss << basename << "_" << std::hex << std::setw(8) << std::setfill('0') << | 86 ss << basename << "_" << std::hex << std::setw(8) << std::setfill('0') << ssrc |
84 ssrc << "." << extension; | 87 << "." << extension; |
85 out_filename_ = ss.str(); | 88 out_filename_ = ss.str(); |
86 } | 89 } |
87 | 90 |
88 FileOutputFrameReceiver::~FileOutputFrameReceiver() { | 91 FileOutputFrameReceiver::~FileOutputFrameReceiver() { |
89 if (timing_file_ != NULL) { | 92 if (timing_file_ != NULL) { |
90 fclose(timing_file_); | 93 fclose(timing_file_); |
91 } | 94 } |
92 if (out_file_ != NULL) { | 95 if (out_file_ != NULL) { |
93 fclose(out_file_); | 96 fclose(out_file_); |
94 } | 97 } |
(...skipping 11 matching lines...) Expand all Loading... |
106 } | 109 } |
107 } | 110 } |
108 if (out_file_ == NULL || video_frame.width() != width_ || | 111 if (out_file_ == NULL || video_frame.width() != width_ || |
109 video_frame.height() != height_) { | 112 video_frame.height() != height_) { |
110 if (out_file_) { | 113 if (out_file_) { |
111 fclose(out_file_); | 114 fclose(out_file_); |
112 } | 115 } |
113 printf("New size: %dx%d\n", video_frame.width(), video_frame.height()); | 116 printf("New size: %dx%d\n", video_frame.width(), video_frame.height()); |
114 width_ = video_frame.width(); | 117 width_ = video_frame.width(); |
115 height_ = video_frame.height(); | 118 height_ = video_frame.height(); |
116 std::string filename_with_width_height = AppendWidthHeightCount( | 119 std::string filename_with_width_height = |
117 out_filename_, width_, height_, count_); | 120 AppendWidthHeightCount(out_filename_, width_, height_, count_); |
118 ++count_; | 121 ++count_; |
119 out_file_ = fopen(filename_with_width_height.c_str(), "wb"); | 122 out_file_ = fopen(filename_with_width_height.c_str(), "wb"); |
120 if (out_file_ == NULL) { | 123 if (out_file_ == NULL) { |
121 return -1; | 124 return -1; |
122 } | 125 } |
123 } | 126 } |
124 fprintf(timing_file_, "%u, %u\n", video_frame.timestamp(), | 127 fprintf(timing_file_, "%u, %u\n", video_frame.timestamp(), |
125 webrtc::MaskWord64ToUWord32(video_frame.render_time_ms())); | 128 webrtc::MaskWord64ToUWord32(video_frame.render_time_ms())); |
126 if (PrintVideoFrame(video_frame, out_file_) < 0) { | 129 if (PrintVideoFrame(video_frame, out_file_) < 0) { |
127 return -1; | 130 return -1; |
128 } | 131 } |
129 return 0; | 132 return 0; |
130 } | 133 } |
131 | 134 |
132 webrtc::RtpVideoCodecTypes ConvertCodecType(const char* plname) { | 135 webrtc::RtpVideoCodecTypes ConvertCodecType(const char* plname) { |
133 if (strncmp(plname,"VP8" , 3) == 0) { | 136 if (strncmp(plname, "VP8", 3) == 0) { |
134 return webrtc::kRtpVideoVp8; | 137 return webrtc::kRtpVideoVp8; |
135 } else { | 138 } else { |
136 // Default value. | 139 // Default value. |
137 return webrtc::kRtpVideoGeneric; | 140 return webrtc::kRtpVideoGeneric; |
138 } | 141 } |
139 } | 142 } |
OLD | NEW |