summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-09 00:10:06 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-09 00:10:06 +0000
commit29b5099e1936f241fec8e991ae9e54237063ce46 (patch)
treef9c964ce622a4242be77918d0e9dc8ff6de609b1 /media
parentc5863e26f5a2ac490270141a12c3fd09ab9552f4 (diff)
downloadchromium_src-29b5099e1936f241fec8e991ae9e54237063ce46.zip
chromium_src-29b5099e1936f241fec8e991ae9e54237063ce46.tar.gz
chromium_src-29b5099e1936f241fec8e991ae9e54237063ce46.tar.bz2
Updated MediaFormat to use std::string and char/wchar_t constants and tweaked MediaFormat::Clear.
Review URL: http://codereview.chromium.org/13211 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6559 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/base/media_format.cc64
-rw-r--r--media/base/media_format.h57
2 files changed, 60 insertions, 61 deletions
diff --git a/media/base/media_format.cc b/media/base/media_format.cc
index 289ae0a..c3f0c89 100644
--- a/media/base/media_format.cc
+++ b/media/base/media_format.cc
@@ -11,30 +11,30 @@ namespace mime_type {
// Represents a URI, typically used to create a DataSourceInterface.
// Expected keys:
// kUri String The URI
-const std::wstring kURI(L"text/x-uri");
+const wchar_t kURI[] = L"text/x-uri";
// Represents a generic byte stream, typically from a DataSourceInterface.
// Expected keys:
// None
-const std::wstring kApplicationOctetStream(L"application/octet-stream");
+const wchar_t kApplicationOctetStream[] = L"application/octet-stream";
// Represents encoded audio data, typically from an DemuxerStreamInterface.
// Expected keys:
// None
-const std::wstring kMPEGAudio(L"audio/mpeg");
-const std::wstring kAACAudio(L"audio/aac");
+const wchar_t kMPEGAudio[] = L"audio/mpeg";
+const wchar_t kAACAudio[] = L"audio/aac";
// Represents encoded video data, typically from a DemuxerStreamInterface.
// Expected keys:
// None
-const std::wstring kH264AnnexB(L"video/x-h264-annex-b");
+const wchar_t kH264AnnexB[] = L"video/x-h264-annex-b";
// Represents decoded audio data, typically from an AudioDecoderInterface.
// Expected keys:
// kChannels Integer Number of audio channels
// kSampleRate Integer Audio sample rate (i.e., 44100)
// kSampleBits Integer Audio bits-per-sample (i.e., 16)
-const std::wstring kRawAudio(L"audio/x-uncompressed");
+const wchar_t kRawAudio[] = L"audio/x-uncompressed";
// Represents decoded video data, typically from a VideoDecoderInterface.
// Other information, such as surface format (i.e., YV12), stride and planes are
@@ -42,26 +42,26 @@ const std::wstring kRawAudio(L"audio/x-uncompressed");
// Expected keys:
// kWidth Integer Display width of the surface
// kHeight Integer Display height of the surface
-const std::wstring kRawVideo(L"video/x-uncompressed");
+const wchar_t kRawVideo[] = L"video/x-uncompressed";
// Represents FFmpeg encoded packets, typically from an DemuxerStreamInterface.
// Expected keys:
// kFfmpegCodecId Integer The FFmpeg CodecID identifying the decoder
-const std::wstring kFFmpegAudio(L"audio/x-ffmpeg");
-const std::wstring kFFmpegVideo(L"video/x-ffmpeg");
+const wchar_t kFFmpegAudio[] = L"audio/x-ffmpeg";
+const wchar_t kFFmpegVideo[] = L"video/x-ffmpeg";
} // namespace mime_type
// Common keys.
-const std::wstring MediaFormat::kMimeType(L"MimeType");
-const std::wstring MediaFormat::kURI(L"Uri");
-const std::wstring MediaFormat::kSurfaceFormat(L"SurfaceFormat");
-const std::wstring MediaFormat::kSampleRate(L"SampleRate");
-const std::wstring MediaFormat::kSampleBits(L"SampleBits");
-const std::wstring MediaFormat::kChannels(L"Channels");
-const std::wstring MediaFormat::kWidth(L"Width");
-const std::wstring MediaFormat::kHeight(L"Height");
-const std::wstring MediaFormat::kFfmpegCodecId(L"FfmpegCodecId");
+const char MediaFormat::kMimeType[] = "MimeType";
+const char MediaFormat::kURI[] = "Uri";
+const char MediaFormat::kSurfaceFormat[] = "SurfaceFormat";
+const char MediaFormat::kSampleRate[] = "SampleRate";
+const char MediaFormat::kSampleBits[] = "SampleBits";
+const char MediaFormat::kChannels[] = "Channels";
+const char MediaFormat::kWidth[] = "Width";
+const char MediaFormat::kHeight[] = "Height";
+const char MediaFormat::kFfmpegCodecId[] = "FfmpegCodecId";
MediaFormat::MediaFormat() {
}
@@ -70,58 +70,56 @@ MediaFormat::~MediaFormat() {
Clear();
}
-bool MediaFormat::Contains(const std::wstring& key) const {
+bool MediaFormat::Contains(const std::string& key) const {
return value_map_.find(key) != value_map_.end();
}
void MediaFormat::Clear() {
- ValueMap::iterator iter(value_map_.begin());
- while (iter != value_map_.end()) {
+ for (ValueMap::iterator iter(value_map_.begin());
+ iter != value_map_.end(); ++iter)
delete iter->second;
- value_map_.erase(iter);
- iter = value_map_.begin();
- }
+ value_map_.clear();
}
-void MediaFormat::SetAsBoolean(const std::wstring& key, bool in_value) {
+void MediaFormat::SetAsBoolean(const std::string& key, bool in_value) {
value_map_[key] = Value::CreateBooleanValue(in_value);
}
-void MediaFormat::SetAsInteger(const std::wstring& key, int in_value) {
+void MediaFormat::SetAsInteger(const std::string& key, int in_value) {
value_map_[key] = Value::CreateIntegerValue(in_value);
}
-void MediaFormat::SetAsReal(const std::wstring& key, double in_value) {
+void MediaFormat::SetAsReal(const std::string& key, double in_value) {
value_map_[key] = Value::CreateRealValue(in_value);
}
-void MediaFormat::SetAsString(const std::wstring& key,
+void MediaFormat::SetAsString(const std::string& key,
const std::wstring& in_value) {
value_map_[key] = Value::CreateStringValue(in_value);
}
-bool MediaFormat::GetAsBoolean(const std::wstring& key, bool* out_value) const {
+bool MediaFormat::GetAsBoolean(const std::string& key, bool* out_value) const {
Value* value = GetValue(key);
return value != NULL && value->GetAsBoolean(out_value);
}
-bool MediaFormat::GetAsInteger(const std::wstring& key, int* out_value) const {
+bool MediaFormat::GetAsInteger(const std::string& key, int* out_value) const {
Value* value = GetValue(key);
return value != NULL && value->GetAsInteger(out_value);
}
-bool MediaFormat::GetAsReal(const std::wstring& key, double* out_value) const {
+bool MediaFormat::GetAsReal(const std::string& key, double* out_value) const {
Value* value = GetValue(key);
return value != NULL && value->GetAsReal(out_value);
}
-bool MediaFormat::GetAsString(const std::wstring& key,
+bool MediaFormat::GetAsString(const std::string& key,
std::wstring* out_value) const {
Value* value = GetValue(key);
return value != NULL && value->GetAsString(out_value);
}
-Value* MediaFormat::GetValue(const std::wstring& key) const {
+Value* MediaFormat::GetValue(const std::string& key) const {
ValueMap::const_iterator value_iter = value_map_.find(key);
return (value_iter == value_map_.end()) ? NULL : value_iter->second;
}
diff --git a/media/base/media_format.h b/media/base/media_format.h
index d1303a2..34b0ee5 100644
--- a/media/base/media_format.h
+++ b/media/base/media_format.h
@@ -11,15 +11,15 @@ namespace media {
// Common MIME types.
namespace mime_type {
-extern const std::wstring kURI;
-extern const std::wstring kApplicationOctetStream;
-extern const std::wstring kMPEGAudio;
-extern const std::wstring kAACAudio;
-extern const std::wstring kH264AnnexB;
-extern const std::wstring kUncompressedAudio;
-extern const std::wstring kUncompressedVideo;
-extern const std::wstring kFFmpegAudio;
-extern const std::wstring kFFmpegVideo;
+extern const wchar_t kURI[];
+extern const wchar_t kApplicationOctetStream[];
+extern const wchar_t kMPEGAudio[];
+extern const wchar_t kAACAudio[];
+extern const wchar_t kH264AnnexB[];
+extern const wchar_t kUncompressedAudio[];
+extern const wchar_t kUncompressedVideo[];
+extern const wchar_t kFFmpegAudio[];
+extern const wchar_t kFFmpegVideo[];
} // namespace mime_type
// MediaFormat is used to describe the output of a MediaFilterInterface to
@@ -41,15 +41,15 @@ extern const std::wstring kFFmpegVideo;
class MediaFormat {
public:
// Common keys.
- static const std::wstring kMimeType;
- static const std::wstring kURI;
- static const std::wstring kSurfaceFormat;
- static const std::wstring kSampleRate;
- static const std::wstring kSampleBits;
- static const std::wstring kChannels;
- static const std::wstring kWidth;
- static const std::wstring kHeight;
- static const std::wstring kFfmpegCodecId;
+ static const char kMimeType[];
+ static const char kURI[];
+ static const char kSurfaceFormat[];
+ static const char kSampleRate[];
+ static const char kSampleBits[];
+ static const char kChannels[];
+ static const char kWidth[];
+ static const char kHeight[];
+ static const char kFfmpegCodecId[];
MediaFormat();
~MediaFormat();
@@ -57,25 +57,26 @@ class MediaFormat {
// Basic map operations.
bool empty() const { return value_map_.empty(); }
- bool Contains(const std::wstring& key) const;
+ bool Contains(const std::string& key) const;
void Clear();
// Value accessors.
- void SetAsBoolean(const std::wstring& key, bool in_value);
- void SetAsInteger(const std::wstring& key, int in_value);
- void SetAsReal(const std::wstring& key, double in_value);
- void SetAsString(const std::wstring& key, const std::wstring& in_value);
+ void SetAsBoolean(const std::string& key, bool in_value);
+ void SetAsInteger(const std::string& key, int in_value);
+ void SetAsReal(const std::string& key, double in_value);
+ void SetAsString(const std::string& key, const std::wstring& in_value);
- bool GetAsBoolean(const std::wstring& key, bool* out_value) const;
- bool GetAsInteger(const std::wstring& key, int* out_value) const;
- bool GetAsReal(const std::wstring& key, double* out_value) const;
- bool GetAsString(const std::wstring& key, std::wstring* out_value) const;
+ bool GetAsBoolean(const std::string& key, bool* out_value) const;
+ bool GetAsInteger(const std::string& key, int* out_value) const;
+ bool GetAsReal(const std::string& key, double* out_value) const;
+ bool GetAsString(const std::string& key, std::wstring* out_value) const;
private:
// Helper to return a value.
- Value* GetValue(const std::wstring& key) const;
+ Value* GetValue(const std::string& key) const;
+ typedef std::map<std::string, Value*> ValueMap;
ValueMap value_map_;
DISALLOW_COPY_AND_ASSIGN(MediaFormat);