| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 } | 132 } |
| 133 LOG(LS_WARNING) << "Created IVF file " << file_name_ | 133 LOG(LS_WARNING) << "Created IVF file " << file_name_ |
| 134 << " for codec data of type " << codec_name | 134 << " for codec data of type " << codec_name |
| 135 << " at resolution " << width_ << " x " << height_ | 135 << " at resolution " << width_ << " x " << height_ |
| 136 << ", using " << (using_capture_timestamps_ ? "1" : "90") | 136 << ", using " << (using_capture_timestamps_ ? "1" : "90") |
| 137 << "kHz clock resolution."; | 137 << "kHz clock resolution."; |
| 138 return true; | 138 return true; |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool IvfFileWriter::WriteFrame(const EncodedImage& encoded_image) { | 141 bool IvfFileWriter::WriteFrame(const EncodedImage& encoded_image) { |
| 142 RTC_DCHECK(file_->Open()); | 142 RTC_DCHECK(file_->is_open()); |
| 143 | 143 |
| 144 if (num_frames_ == 0 && !InitFromFirstFrame(encoded_image)) | 144 if (num_frames_ == 0 && !InitFromFirstFrame(encoded_image)) |
| 145 return false; | 145 return false; |
| 146 | 146 |
| 147 if ((encoded_image._encodedWidth > 0 || encoded_image._encodedHeight > 0) && | 147 if ((encoded_image._encodedWidth > 0 || encoded_image._encodedHeight > 0) && |
| 148 (encoded_image._encodedHeight != height_ || | 148 (encoded_image._encodedHeight != height_ || |
| 149 encoded_image._encodedWidth != width_)) { | 149 encoded_image._encodedWidth != width_)) { |
| 150 LOG(LS_WARNING) | 150 LOG(LS_WARNING) |
| 151 << "Incomig frame has diffferent resolution then previous: (" << width_ | 151 << "Incomig frame has diffferent resolution then previous: (" << width_ |
| 152 << "x" << height_ << ") -> (" << encoded_image._encodedWidth << "x" | 152 << "x" << height_ << ") -> (" << encoded_image._encodedWidth << "x" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 171 !file_->Write(encoded_image._buffer, encoded_image._length)) { | 171 !file_->Write(encoded_image._buffer, encoded_image._length)) { |
| 172 LOG(LS_ERROR) << "Unable to write frame to file " << file_name_; | 172 LOG(LS_ERROR) << "Unable to write frame to file " << file_name_; |
| 173 return false; | 173 return false; |
| 174 } | 174 } |
| 175 | 175 |
| 176 ++num_frames_; | 176 ++num_frames_; |
| 177 return true; | 177 return true; |
| 178 } | 178 } |
| 179 | 179 |
| 180 bool IvfFileWriter::Close() { | 180 bool IvfFileWriter::Close() { |
| 181 if (!file_->Open()) | 181 if (!file_->is_open()) |
| 182 return false; | 182 return false; |
| 183 | 183 |
| 184 if (num_frames_ == 0) { | 184 if (num_frames_ == 0) { |
| 185 // No frame written to file, close and remove it entirely if possible. | 185 // No frame written to file, close and remove it entirely if possible. |
| 186 file_->CloseFile(); | 186 file_->CloseFile(); |
| 187 if (remove(file_name_.c_str()) != 0) | 187 if (remove(file_name_.c_str()) != 0) |
| 188 LOG(LS_WARNING) << "Failed to remove empty IVF file " << file_name_; | 188 LOG(LS_WARNING) << "Failed to remove empty IVF file " << file_name_; |
| 189 | 189 |
| 190 return true; | 190 return true; |
| 191 } | 191 } |
| 192 | 192 |
| 193 return WriteHeader() && (file_->CloseFile() == 0); | 193 bool ret = WriteHeader(); |
| 194 file_->CloseFile(); |
| 195 return ret; |
| 194 } | 196 } |
| 195 | 197 |
| 196 } // namespace webrtc | 198 } // namespace webrtc |
| OLD | NEW |