diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/media/MediaContentType.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/media/MediaContentType.h')
-rw-r--r-- | dom/media/MediaContentType.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/dom/media/MediaContentType.h b/dom/media/MediaContentType.h new file mode 100644 index 000000000..67078757a --- /dev/null +++ b/dom/media/MediaContentType.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef MediaContentType_h_ +#define MediaContentType_h_ + +#include "mozilla/Maybe.h" +#include "nsString.h" + +namespace mozilla { + +// Structure containing pre-parsed content type parameters, e.g.: +// MIME type, optional codecs, etc. +class MediaContentType +{ +public: + // Parse UTF16 string to extract parameters. + explicit MediaContentType(const nsAString& aType); + // Parse UTF8 string to extract parameters. + explicit MediaContentType(const nsACString& aType); + + bool IsValid() const { return !GetMIMEType().IsEmpty(); } + + // MIME type. Empty if construction arguments could not be parsed. + const nsACString& GetMIMEType() const { return mMIMEType; } + + // Was there an explicit 'codecs' parameter provided? + bool HaveCodecs() const { return mHaveCodecs; } + // Codecs. May be empty if not provided or explicitly provided as empty. + const nsAString& GetCodecs() const { return mCodecs; } + + // Sizes and rates. + Maybe<int32_t> GetWidth() const { return GetMaybeNumber(mWidth); } + Maybe<int32_t> GetHeight() const { return GetMaybeNumber(mHeight); } + Maybe<int32_t> GetFramerate() const { return GetMaybeNumber(mFramerate); } + Maybe<int32_t> GetBitrate() const { return GetMaybeNumber(mBitrate); } + +private: + void Populate(const nsAString& aType); + + Maybe<int32_t> GetMaybeNumber(int32_t aNumber) const + { + return (aNumber < 0) ? Maybe<int32_t>(Nothing()) : Some(int32_t(aNumber)); + } + + nsCString mMIMEType; // UTF8 MIME type. Empty if parsing failed. + bool mHaveCodecs; // If false, mCodecs must be empty. + nsString mCodecs; + int32_t mWidth; // -1 if not provided. + int32_t mHeight; // -1 if not provided. + int32_t mFramerate; // -1 if not provided. + int32_t mBitrate; // -1 if not provided. +}; + +} // namespace mozilla + +#endif // MediaContentType_h_ |