| 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" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 | 51 |
| 52 AudioVideoMetadataExtractor::AudioVideoMetadataExtractor() | 52 AudioVideoMetadataExtractor::AudioVideoMetadataExtractor() |
| 53 : extracted_(false), | 53 : extracted_(false), |
| 54 duration_(-1), | 54 duration_(-1), |
| 55 width_(-1), | 55 width_(-1), |
| 56 height_(-1), | 56 height_(-1), |
| 57 disc_(-1), | 57 disc_(-1), |
| 58 rotation_(-1), |
| 58 track_(-1) { | 59 track_(-1) { |
| 59 } | 60 } |
| 60 | 61 |
| 61 AudioVideoMetadataExtractor::~AudioVideoMetadataExtractor() { | 62 AudioVideoMetadataExtractor::~AudioVideoMetadataExtractor() { |
| 62 } | 63 } |
| 63 | 64 |
| 64 bool AudioVideoMetadataExtractor::Extract(DataSource* source) { | 65 bool AudioVideoMetadataExtractor::Extract(DataSource* source) { |
| 65 DCHECK(!extracted_); | 66 DCHECK(!extracted_); |
| 66 | 67 |
| 67 bool read_ok = true; | 68 bool read_ok = true; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 int AudioVideoMetadataExtractor::width() const { | 123 int AudioVideoMetadataExtractor::width() const { |
| 123 DCHECK(extracted_); | 124 DCHECK(extracted_); |
| 124 return width_; | 125 return width_; |
| 125 } | 126 } |
| 126 | 127 |
| 127 int AudioVideoMetadataExtractor::height() const { | 128 int AudioVideoMetadataExtractor::height() const { |
| 128 DCHECK(extracted_); | 129 DCHECK(extracted_); |
| 129 return height_; | 130 return height_; |
| 130 } | 131 } |
| 131 | 132 |
| 133 int AudioVideoMetadataExtractor::rotation() const { |
| 134 DCHECK(extracted_); |
| 135 return rotation_; |
| 136 } |
| 137 |
| 132 const std::string& AudioVideoMetadataExtractor::album() const { | 138 const std::string& AudioVideoMetadataExtractor::album() const { |
| 133 DCHECK(extracted_); | 139 DCHECK(extracted_); |
| 134 return album_; | 140 return album_; |
| 135 } | 141 } |
| 136 | 142 |
| 137 const std::string& AudioVideoMetadataExtractor::artist() const { | 143 const std::string& AudioVideoMetadataExtractor::artist() const { |
| 138 DCHECK(extracted_); | 144 DCHECK(extracted_); |
| 139 return artist_; | 145 return artist_; |
| 140 } | 146 } |
| 141 | 147 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 DCHECK(extracted_); | 194 DCHECK(extracted_); |
| 189 return track_; | 195 return track_; |
| 190 } | 196 } |
| 191 | 197 |
| 192 void AudioVideoMetadataExtractor::ExtractDictionary(AVDictionary* metadata) { | 198 void AudioVideoMetadataExtractor::ExtractDictionary(AVDictionary* metadata) { |
| 193 if (!metadata) | 199 if (!metadata) |
| 194 return; | 200 return; |
| 195 | 201 |
| 196 AVDictionaryEntry* tag = NULL; | 202 AVDictionaryEntry* tag = NULL; |
| 197 while ((tag = av_dict_get(metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { | 203 while ((tag = av_dict_get(metadata, "", tag, AV_DICT_IGNORE_SUFFIX))) { |
| 204 if (ExtractInt(tag, "rotate", &rotation_)) continue; |
| 198 if (ExtractString(tag, "album", &album_)) continue; | 205 if (ExtractString(tag, "album", &album_)) continue; |
| 199 if (ExtractString(tag, "artist", &artist_)) continue; | 206 if (ExtractString(tag, "artist", &artist_)) continue; |
| 200 if (ExtractString(tag, "comment", &comment_)) continue; | 207 if (ExtractString(tag, "comment", &comment_)) continue; |
| 201 if (ExtractString(tag, "copyright", ©right_)) continue; | 208 if (ExtractString(tag, "copyright", ©right_)) continue; |
| 202 if (ExtractString(tag, "date", &date_)) continue; | 209 if (ExtractString(tag, "date", &date_)) continue; |
| 203 if (ExtractInt(tag, "disc", &disc_)) continue; | 210 if (ExtractInt(tag, "disc", &disc_)) continue; |
| 204 if (ExtractString(tag, "encoder", &encoder_)) continue; | 211 if (ExtractString(tag, "encoder", &encoder_)) continue; |
| 205 if (ExtractString(tag, "encoded_by", &encoded_by_)) continue; | 212 if (ExtractString(tag, "encoded_by", &encoded_by_)) continue; |
| 206 if (ExtractString(tag, "genre", &genre_)) continue; | 213 if (ExtractString(tag, "genre", &genre_)) continue; |
| 207 if (ExtractString(tag, "language", &language_)) continue; | 214 if (ExtractString(tag, "language", &language_)) continue; |
| 208 if (ExtractString(tag, "title", &title_)) continue; | 215 if (ExtractString(tag, "title", &title_)) continue; |
| 209 if (ExtractInt(tag, "track", &track_)) continue; | 216 if (ExtractInt(tag, "track", &track_)) continue; |
| 210 } | 217 } |
| 211 } | 218 } |
| 212 | 219 |
| 213 } // namespace media | 220 } // namespace media |
| OLD | NEW |