| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/media_file_checker.h" | 5 #include "media/base/media_file_checker.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 if (codec && avcodec_open2(c, codec, NULL) >= 0) | 53 if (codec && avcodec_open2(c, codec, NULL) >= 0) |
| 54 stream_contexts[i] = c; | 54 stream_contexts[i] = c; |
| 55 } | 55 } |
| 56 } | 56 } |
| 57 | 57 |
| 58 if (stream_contexts.size() == 0) | 58 if (stream_contexts.size() == 0) |
| 59 return false; | 59 return false; |
| 60 | 60 |
| 61 AVPacket packet; | 61 AVPacket packet; |
| 62 scoped_ptr_malloc<AVFrame, media::ScopedPtrAVFreeFrame> frame( | 62 scoped_ptr_malloc<AVFrame, media::ScopedPtrAVFreeFrame> frame( |
| 63 avcodec_alloc_frame()); | 63 av_frame_alloc()); |
| 64 int result = 0; | 64 int result = 0; |
| 65 | 65 |
| 66 base::Time deadline = base::Time::Now() + | 66 base::Time deadline = base::Time::Now() + |
| 67 std::min(check_time, | 67 std::min(check_time, |
| 68 base::TimeDelta::FromSeconds(kMaxCheckTimeInSeconds)); | 68 base::TimeDelta::FromSeconds(kMaxCheckTimeInSeconds)); |
| 69 do { | 69 do { |
| 70 result = av_read_frame(glue.format_context(), &packet); | 70 result = av_read_frame(glue.format_context(), &packet); |
| 71 if (result < 0) | 71 if (result < 0) |
| 72 break; | 72 break; |
| 73 result = av_dup_packet(&packet); | 73 result = av_dup_packet(&packet); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 101 result = avcodec_decode_video2(av_context, frame.get(), &frame_decoded, | 101 result = avcodec_decode_video2(av_context, frame.get(), &frame_decoded, |
| 102 &packet); | 102 &packet); |
| 103 } | 103 } |
| 104 av_free_packet(&packet); | 104 av_free_packet(&packet); |
| 105 } while (base::Time::Now() < deadline && read_ok && result >= 0); | 105 } while (base::Time::Now() < deadline && read_ok && result >= 0); |
| 106 | 106 |
| 107 return read_ok && (result == AVERROR_EOF || result >= 0); | 107 return read_ok && (result == AVERROR_EOF || result >= 0); |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace media | 110 } // namespace media |
| OLD | NEW |