| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license | |
| 5 * that can be found in the LICENSE file in the root of the source | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #ifndef WEBRTC_MEDIA_BASE_HYBRIDDATAENGINE_H_ | |
| 12 #define WEBRTC_MEDIA_BASE_HYBRIDDATAENGINE_H_ | |
| 13 | |
| 14 #include <memory> | |
| 15 #include <string> | |
| 16 #include <vector> | |
| 17 | |
| 18 #include "webrtc/media/base/codec.h" | |
| 19 #include "webrtc/media/base/mediachannel.h" | |
| 20 #include "webrtc/media/base/mediaengine.h" | |
| 21 | |
| 22 namespace cricket { | |
| 23 | |
| 24 class HybridDataEngine : public DataEngineInterface { | |
| 25 public: | |
| 26 // Takes ownership. | |
| 27 HybridDataEngine(DataEngineInterface* first, | |
| 28 DataEngineInterface* second) | |
| 29 : first_(first), | |
| 30 second_(second) { | |
| 31 codecs_ = first_->data_codecs(); | |
| 32 codecs_.insert( | |
| 33 codecs_.end(), | |
| 34 second_->data_codecs().begin(), | |
| 35 second_->data_codecs().end()); | |
| 36 } | |
| 37 | |
| 38 virtual DataMediaChannel* CreateChannel(DataChannelType data_channel_type, | |
| 39 const MediaConfig& config) { | |
| 40 DataMediaChannel* channel = NULL; | |
| 41 if (first_) { | |
| 42 channel = first_->CreateChannel(data_channel_type, config); | |
| 43 } | |
| 44 if (!channel && second_) { | |
| 45 channel = second_->CreateChannel(data_channel_type, config); | |
| 46 } | |
| 47 return channel; | |
| 48 } | |
| 49 | |
| 50 virtual const std::vector<DataCodec>& data_codecs() { return codecs_; } | |
| 51 | |
| 52 private: | |
| 53 std::unique_ptr<DataEngineInterface> first_; | |
| 54 std::unique_ptr<DataEngineInterface> second_; | |
| 55 std::vector<DataCodec> codecs_; | |
| 56 }; | |
| 57 | |
| 58 } // namespace cricket | |
| 59 | |
| 60 #endif // WEBRTC_MEDIA_BASE_HYBRIDDATAENGINE_H_ | |
| OLD | NEW |