1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 sts=2 et cindent: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef MediaContainerType_h_
8 #define MediaContainerType_h_
9 
10 #include "MediaMIMETypes.h"
11 #include "mozilla/Maybe.h"
12 #include "nsString.h"
13 
14 namespace mozilla {
15 
16 // Class containing media type information for containers.
17 class MediaContainerType {
18  public:
MediaContainerType(const MediaMIMEType & aType)19   explicit MediaContainerType(const MediaMIMEType& aType)
20       : mExtendedMIMEType(aType) {}
MediaContainerType(MediaMIMEType && aType)21   explicit MediaContainerType(MediaMIMEType&& aType)
22       : mExtendedMIMEType(std::move(aType)) {}
MediaContainerType(const MediaExtendedMIMEType & aType)23   explicit MediaContainerType(const MediaExtendedMIMEType& aType)
24       : mExtendedMIMEType(aType) {}
MediaContainerType(MediaExtendedMIMEType && aType)25   explicit MediaContainerType(MediaExtendedMIMEType&& aType)
26       : mExtendedMIMEType(std::move(aType)) {}
27 
Type()28   const MediaMIMEType& Type() const { return mExtendedMIMEType.Type(); }
ExtendedType()29   const MediaExtendedMIMEType& ExtendedType() const {
30     return mExtendedMIMEType;
31   }
32 
33   // Original string. Note that "type/subtype" may not be lowercase,
34   // use Type().AsString() instead to get the normalized "type/subtype".
OriginalString()35   const nsCString& OriginalString() const {
36     return mExtendedMIMEType.OriginalString();
37   }
38 
39   size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
40 
41  private:
42   MediaExtendedMIMEType mExtendedMIMEType;
43 };
44 
45 Maybe<MediaContainerType> MakeMediaContainerType(const nsAString& aType);
46 Maybe<MediaContainerType> MakeMediaContainerType(const nsACString& aType);
47 Maybe<MediaContainerType> MakeMediaContainerType(const char* aType);
48 
49 }  // namespace mozilla
50 
51 #endif  // MediaContainerType_h_
52