OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/audio_video_metadata_extractor.h" | 5 #include "media/base/audio_video_metadata_extractor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/ffmpeg/ffmpeg_common.h" | 11 #include "media/ffmpeg/ffmpeg_common.h" |
12 #include "media/filters/blocking_url_protocol.h" | 12 #include "media/filters/blocking_url_protocol.h" |
13 #include "media/filters/ffmpeg_glue.h" | 13 #include "media/filters/ffmpeg_glue.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 void OnError(bool* succeeded) { | 19 void OnError(bool* succeeded) { |
20 *succeeded = false; | 20 *succeeded = false; |
21 } | 21 } |
22 | 22 |
23 // Returns true if the |tag| matches |expected_key|. | 23 // Returns true if the |tag| matches |expected_key|. |
24 bool ExtractString(AVDictionaryEntry* tag, const char* expected_key, | 24 bool ExtractString(AVDictionaryEntry* tag, const char* expected_key, |
25 std::string* destination) { | 25 std::string* destination) { |
26 if (!base::LowerCaseEqualsASCII(tag->key, expected_key)) | 26 if (!LowerCaseEqualsASCII(std::string(tag->key), expected_key)) |
27 return false; | 27 return false; |
28 | 28 |
29 if (destination->empty()) | 29 if (destination->empty()) |
30 *destination = tag->value; | 30 *destination = tag->value; |
31 | 31 |
32 return true; | 32 return true; |
33 } | 33 } |
34 | 34 |
35 // Returns true if the |tag| matches |expected_key|. | 35 // Returns true if the |tag| matches |expected_key|. |
36 bool ExtractInt(AVDictionaryEntry* tag, const char* expected_key, | 36 bool ExtractInt(AVDictionaryEntry* tag, const char* expected_key, |
37 int* destination) { | 37 int* destination) { |
38 if (!base::LowerCaseEqualsASCII(tag->key, expected_key)) | 38 if (!LowerCaseEqualsASCII(std::string(tag->key), expected_key)) |
39 return false; | 39 return false; |
40 | 40 |
41 int temporary = -1; | 41 int temporary = -1; |
42 if (*destination < 0 && base::StringToInt(tag->value, &temporary) && | 42 if (*destination < 0 && base::StringToInt(tag->value, &temporary) && |
43 temporary >= 0) { | 43 temporary >= 0) { |
44 *destination = temporary; | 44 *destination = temporary; |
45 } | 45 } |
46 | 46 |
47 return true; | 47 return true; |
48 } | 48 } |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 if (ExtractString(tag, "encoder", &encoder_)) continue; | 252 if (ExtractString(tag, "encoder", &encoder_)) continue; |
253 if (ExtractString(tag, "encoded_by", &encoded_by_)) continue; | 253 if (ExtractString(tag, "encoded_by", &encoded_by_)) continue; |
254 if (ExtractString(tag, "genre", &genre_)) continue; | 254 if (ExtractString(tag, "genre", &genre_)) continue; |
255 if (ExtractString(tag, "language", &language_)) continue; | 255 if (ExtractString(tag, "language", &language_)) continue; |
256 if (ExtractString(tag, "title", &title_)) continue; | 256 if (ExtractString(tag, "title", &title_)) continue; |
257 if (ExtractInt(tag, "track", &track_)) continue; | 257 if (ExtractInt(tag, "track", &track_)) continue; |
258 } | 258 } |
259 } | 259 } |
260 | 260 |
261 } // namespace media | 261 } // namespace media |
OLD | NEW |