You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
4.0 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * libjingle
  3. * Copyright 2004--2005, Google Inc.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice,
  9. * this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright notice,
  11. * this list of conditions and the following disclaimer in the documentation
  12. * and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  19. * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  21. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  22. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  23. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  24. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  25. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #ifndef TALK_P2P_BASE_SESSIONCLIENT_H_
  28. #define TALK_P2P_BASE_SESSIONCLIENT_H_
  29. #include "talk/p2p/base/constants.h"
  30. namespace buzz {
  31. class XmlElement;
  32. }
  33. namespace cricket {
  34. struct ParseError;
  35. class Session;
  36. class ContentDescription;
  37. class ContentParser {
  38. public:
  39. virtual bool ParseContent(SignalingProtocol protocol,
  40. const buzz::XmlElement* elem,
  41. ContentDescription** content,
  42. ParseError* error) = 0;
  43. // If not IsWriteable, then a given content should be "skipped" when
  44. // writing in the given protocol, as if it didn't exist. We assume
  45. // most things are writeable. We do this to avoid strange cases
  46. // like data contents in Gingle, which aren't writable.
  47. virtual bool IsWritable(SignalingProtocol protocol,
  48. const ContentDescription* content) {
  49. return true;
  50. }
  51. virtual bool WriteContent(SignalingProtocol protocol,
  52. const ContentDescription* content,
  53. buzz::XmlElement** elem,
  54. WriteError* error) = 0;
  55. virtual ~ContentParser() {}
  56. };
  57. // A SessionClient exists in 1-1 relation with each session. The implementor
  58. // of this interface is the one that understands *what* the two sides are
  59. // trying to send to one another. The lower-level layers only know how to send
  60. // data; they do not know what is being sent.
  61. class SessionClient : public ContentParser {
  62. public:
  63. // Notifies the client of the creation / destruction of sessions of this type.
  64. //
  65. // IMPORTANT: The SessionClient, in its handling of OnSessionCreate, must
  66. // create whatever channels are indicate in the description. This is because
  67. // the remote client may already be attempting to connect those channels. If
  68. // we do not create our channel right away, then connection may fail or be
  69. // delayed.
  70. virtual void OnSessionCreate(Session* session, bool received_initiate) = 0;
  71. virtual void OnSessionDestroy(Session* session) = 0;
  72. virtual bool ParseContent(SignalingProtocol protocol,
  73. const buzz::XmlElement* elem,
  74. ContentDescription** content,
  75. ParseError* error) = 0;
  76. virtual bool WriteContent(SignalingProtocol protocol,
  77. const ContentDescription* content,
  78. buzz::XmlElement** elem,
  79. WriteError* error) = 0;
  80. protected:
  81. // The SessionClient interface explicitly does not include destructor
  82. virtual ~SessionClient() { }
  83. };
  84. } // namespace cricket
  85. #endif // TALK_P2P_BASE_SESSIONCLIENT_H_