| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2004 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_P2P_BASE_SESSIONCLIENT_H_ | |
| 12 #define WEBRTC_P2P_BASE_SESSIONCLIENT_H_ | |
| 13 | |
| 14 #include "webrtc/libjingle/session/constants.h" | |
| 15 #include "webrtc/p2p/base/constants.h" | |
| 16 | |
| 17 namespace buzz { | |
| 18 class XmlElement; | |
| 19 } | |
| 20 | |
| 21 namespace cricket { | |
| 22 | |
| 23 struct ParseError; | |
| 24 struct WriteError; | |
| 25 class Session; | |
| 26 class ContentDescription; | |
| 27 | |
| 28 class ContentParser { | |
| 29 public: | |
| 30 virtual bool ParseContent(SignalingProtocol protocol, | |
| 31 const buzz::XmlElement* elem, | |
| 32 ContentDescription** content, | |
| 33 ParseError* error) = 0; | |
| 34 // If not IsWriteable, then a given content should be "skipped" when | |
| 35 // writing in the given protocol, as if it didn't exist. We assume | |
| 36 // most things are writeable. We do this to avoid strange cases | |
| 37 // like data contents in Gingle, which aren't writable. | |
| 38 virtual bool IsWritable(SignalingProtocol protocol, | |
| 39 const ContentDescription* content) { | |
| 40 return true; | |
| 41 } | |
| 42 virtual bool WriteContent(SignalingProtocol protocol, | |
| 43 const ContentDescription* content, | |
| 44 buzz::XmlElement** elem, | |
| 45 WriteError* error) = 0; | |
| 46 virtual ~ContentParser() {} | |
| 47 }; | |
| 48 | |
| 49 // A SessionClient exists in 1-1 relation with each session. The implementor | |
| 50 // of this interface is the one that understands *what* the two sides are | |
| 51 // trying to send to one another. The lower-level layers only know how to send | |
| 52 // data; they do not know what is being sent. | |
| 53 class SessionClient : public ContentParser { | |
| 54 public: | |
| 55 // Notifies the client of the creation / destruction of sessions of this type. | |
| 56 // | |
| 57 // IMPORTANT: The SessionClient, in its handling of OnSessionCreate, must | |
| 58 // create whatever channels are indicate in the description. This is because | |
| 59 // the remote client may already be attempting to connect those channels. If | |
| 60 // we do not create our channel right away, then connection may fail or be | |
| 61 // delayed. | |
| 62 virtual void OnSessionCreate(Session* session, bool received_initiate) = 0; | |
| 63 virtual void OnSessionDestroy(Session* session) = 0; | |
| 64 | |
| 65 virtual bool ParseContent(SignalingProtocol protocol, | |
| 66 const buzz::XmlElement* elem, | |
| 67 ContentDescription** content, | |
| 68 ParseError* error) = 0; | |
| 69 virtual bool WriteContent(SignalingProtocol protocol, | |
| 70 const ContentDescription* content, | |
| 71 buzz::XmlElement** elem, | |
| 72 WriteError* error) = 0; | |
| 73 protected: | |
| 74 // The SessionClient interface explicitly does not include destructor | |
| 75 virtual ~SessionClient() { } | |
| 76 }; | |
| 77 | |
| 78 } // namespace cricket | |
| 79 | |
| 80 #endif // WEBRTC_P2P_BASE_SESSIONCLIENT_H_ | |
| OLD | NEW |