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 "jsep/JsepCodecDescription.h" 11 #include "common/EncodingConstraints.h" 12 13 #include <vector> 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; JsepTrackEncoding(const JsepTrackEncoding & orig)23 JsepTrackEncoding(const JsepTrackEncoding& orig) 24 : mConstraints(orig.mConstraints), mRid(orig.mRid) { 25 for (const auto& codec : orig.mCodecs) { 26 mCodecs.emplace_back(codec->Clone()); 27 } 28 } 29 GetCodecs()30 const std::vector<UniquePtr<JsepCodecDescription>>& GetCodecs() const { 31 return mCodecs; 32 } 33 AddCodec(const JsepCodecDescription & codec)34 void AddCodec(const JsepCodecDescription& codec) { 35 mCodecs.emplace_back(codec.Clone()); 36 } 37 HasFormat(const std::string & format)38 bool HasFormat(const std::string& format) const { 39 for (const auto& codec : mCodecs) { 40 if (codec->mDefaultPt == format) { 41 return true; 42 } 43 } 44 return false; 45 } 46 47 EncodingConstraints mConstraints; 48 std::string mRid; 49 bool mPaused = false; 50 51 private: 52 std::vector<UniquePtr<JsepCodecDescription>> mCodecs; 53 }; 54 } // namespace mozilla 55 56 #endif // _JESPTRACKENCODING_H_ 57