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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <map> | 9 #include <map> |
| 10 #include <memory> |
10 #include <utility> | 11 #include <utility> |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "media/ffmpeg/ffmpeg_common.h" | 15 #include "media/ffmpeg/ffmpeg_common.h" |
15 #include "media/filters/blocking_url_protocol.h" | 16 #include "media/filters/blocking_url_protocol.h" |
16 #include "media/filters/ffmpeg_glue.h" | 17 #include "media/filters/ffmpeg_glue.h" |
17 #include "media/filters/file_data_source.h" | 18 #include "media/filters/file_data_source.h" |
18 | 19 |
19 namespace media { | 20 namespace media { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 AVCodec* codec = avcodec_find_decoder(c->codec_id); | 52 AVCodec* codec = avcodec_find_decoder(c->codec_id); |
52 if (codec && avcodec_open2(c, codec, NULL) >= 0) | 53 if (codec && avcodec_open2(c, codec, NULL) >= 0) |
53 stream_contexts[i] = c; | 54 stream_contexts[i] = c; |
54 } | 55 } |
55 } | 56 } |
56 | 57 |
57 if (stream_contexts.size() == 0) | 58 if (stream_contexts.size() == 0) |
58 return false; | 59 return false; |
59 | 60 |
60 AVPacket packet; | 61 AVPacket packet; |
61 scoped_ptr<AVFrame, media::ScopedPtrAVFreeFrame> frame(av_frame_alloc()); | 62 std::unique_ptr<AVFrame, media::ScopedPtrAVFreeFrame> frame(av_frame_alloc()); |
62 int result = 0; | 63 int result = 0; |
63 | 64 |
64 const base::TimeTicks deadline = base::TimeTicks::Now() + | 65 const base::TimeTicks deadline = base::TimeTicks::Now() + |
65 std::min(check_time, | 66 std::min(check_time, |
66 base::TimeDelta::FromSeconds(kMaxCheckTimeInSeconds)); | 67 base::TimeDelta::FromSeconds(kMaxCheckTimeInSeconds)); |
67 do { | 68 do { |
68 result = av_read_frame(glue.format_context(), &packet); | 69 result = av_read_frame(glue.format_context(), &packet); |
69 if (result < 0) | 70 if (result < 0) |
70 break; | 71 break; |
71 | 72 |
(...skipping 26 matching lines...) Expand all Loading... |
98 if (result >= 0 && frame_decoded) | 99 if (result >= 0 && frame_decoded) |
99 av_frame_unref(frame.get()); | 100 av_frame_unref(frame.get()); |
100 } | 101 } |
101 av_packet_unref(&packet); | 102 av_packet_unref(&packet); |
102 } while (base::TimeTicks::Now() < deadline && read_ok && result >= 0); | 103 } while (base::TimeTicks::Now() < deadline && read_ok && result >= 0); |
103 | 104 |
104 return read_ok && (result == AVERROR_EOF || result >= 0); | 105 return read_ok && (result == AVERROR_EOF || result >= 0); |
105 } | 106 } |
106 | 107 |
107 } // namespace media | 108 } // namespace media |
OLD | NEW |