JsepTrackEncoding.h (1756B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=2 et sw=2 tw=80: */ 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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef _JESPTRACKENCODING_H_ 8 #define _JESPTRACKENCODING_H_ 9 10 #include <vector> 11 12 #include "common/EncodingConstraints.h" 13 #include "jsep/JsepCodecDescription.h" 14 15 namespace mozilla { 16 // Represents a single encoding of a media track. When simulcast is used, there 17 // may be multiple. Each encoding may have some constraints (imposed by JS), and 18 // may be able to use any one of multiple codecs (JsepCodecDescription) at any 19 // given time. 20 class JsepTrackEncoding { 21 public: 22 JsepTrackEncoding() = default; 23 JsepTrackEncoding(const JsepTrackEncoding& orig) { *this = orig; } 24 25 JsepTrackEncoding(JsepTrackEncoding&& aOrig) = default; 26 27 JsepTrackEncoding& operator=(const JsepTrackEncoding& aRhs) { 28 if (this != &aRhs) { 29 mRid = aRhs.mRid; 30 mCodecs.clear(); 31 for (const auto& codec : aRhs.mCodecs) { 32 mCodecs.emplace_back(codec->Clone()); 33 } 34 } 35 return *this; 36 } 37 38 const std::vector<UniquePtr<JsepCodecDescription>>& GetCodecs() const { 39 return mCodecs; 40 } 41 42 void AddCodec(const JsepCodecDescription& codec) { 43 mCodecs.emplace_back(codec.Clone()); 44 } 45 46 bool HasFormat(const std::string& format) const { 47 for (const auto& codec : mCodecs) { 48 if (codec->mDefaultPt == format) { 49 return true; 50 } 51 } 52 return false; 53 } 54 55 std::string mRid; 56 57 private: 58 std::vector<UniquePtr<JsepCodecDescription>> mCodecs; 59 }; 60 } // namespace mozilla 61 62 #endif // _JESPTRACKENCODING_H_