OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 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 <string> |
| 15 #include <vector> |
| 16 |
| 17 #include "webrtc/base/scoped_ptr.h" |
| 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 DataMediaChannel* channel = NULL; |
| 40 if (first_) { |
| 41 channel = first_->CreateChannel(data_channel_type); |
| 42 } |
| 43 if (!channel && second_) { |
| 44 channel = second_->CreateChannel(data_channel_type); |
| 45 } |
| 46 return channel; |
| 47 } |
| 48 |
| 49 virtual const std::vector<DataCodec>& data_codecs() { return codecs_; } |
| 50 |
| 51 private: |
| 52 rtc::scoped_ptr<DataEngineInterface> first_; |
| 53 rtc::scoped_ptr<DataEngineInterface> second_; |
| 54 std::vector<DataCodec> codecs_; |
| 55 }; |
| 56 |
| 57 } // namespace cricket |
| 58 |
| 59 #endif // WEBRTC_MEDIA_BASE_HYBRIDDATAENGINE_H_ |
OLD | NEW |