| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 explicit SctpFakeNetworkInterface(rtc::Thread* thread) | 57 explicit SctpFakeNetworkInterface(rtc::Thread* thread) |
| 58 : thread_(thread), | 58 : thread_(thread), |
| 59 dest_(NULL) { | 59 dest_(NULL) { |
| 60 } | 60 } |
| 61 | 61 |
| 62 void SetDestination(cricket::DataMediaChannel* dest) { dest_ = dest; } | 62 void SetDestination(cricket::DataMediaChannel* dest) { dest_ = dest; } |
| 63 | 63 |
| 64 protected: | 64 protected: |
| 65 // Called to send raw packet down the wire (e.g. SCTP an packet). | 65 // Called to send raw packet down the wire (e.g. SCTP an packet). |
| 66 virtual bool SendPacket(rtc::Buffer* packet, | 66 virtual bool SendPacket(rtc::Buffer* packet, |
| 67 rtc::DiffServCodePoint dscp) { | 67 const rtc::PacketOptions& options) { |
| 68 LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket"; | 68 LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket"; |
| 69 | 69 |
| 70 // TODO(ldixon): Can/should we use Buffer.TransferTo here? | 70 // TODO(ldixon): Can/should we use Buffer.TransferTo here? |
| 71 // Note: this assignment does a deep copy of data from packet. | 71 // Note: this assignment does a deep copy of data from packet. |
| 72 rtc::Buffer* buffer = new rtc::Buffer(packet->data(), packet->size()); | 72 rtc::Buffer* buffer = new rtc::Buffer(packet->data(), packet->size()); |
| 73 thread_->Post(this, MSG_PACKET, rtc::WrapMessageData(buffer)); | 73 thread_->Post(this, MSG_PACKET, rtc::WrapMessageData(buffer)); |
| 74 LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket, Posted message."; | 74 LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::SendPacket, Posted message."; |
| 75 return true; | 75 return true; |
| 76 } | 76 } |
| 77 | 77 |
| 78 // Called when a raw packet has been recieved. This passes the data to the | 78 // Called when a raw packet has been recieved. This passes the data to the |
| 79 // code that will interpret the packet. e.g. to get the content payload from | 79 // code that will interpret the packet. e.g. to get the content payload from |
| 80 // an SCTP packet. | 80 // an SCTP packet. |
| 81 virtual void OnMessage(rtc::Message* msg) { | 81 virtual void OnMessage(rtc::Message* msg) { |
| 82 LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::OnMessage"; | 82 LOG(LS_VERBOSE) << "SctpFakeNetworkInterface::OnMessage"; |
| 83 rtc::scoped_ptr<rtc::Buffer> buffer( | 83 rtc::scoped_ptr<rtc::Buffer> buffer( |
| 84 static_cast<rtc::TypedMessageData<rtc::Buffer*>*>( | 84 static_cast<rtc::TypedMessageData<rtc::Buffer*>*>( |
| 85 msg->pdata)->data()); | 85 msg->pdata)->data()); |
| 86 if (dest_) { | 86 if (dest_) { |
| 87 dest_->OnPacketReceived(buffer.get(), rtc::PacketTime()); | 87 dest_->OnPacketReceived(buffer.get(), rtc::PacketTime()); |
| 88 } | 88 } |
| 89 delete msg->pdata; | 89 delete msg->pdata; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Unsupported functions required to exist by NetworkInterface. | 92 // Unsupported functions required to exist by NetworkInterface. |
| 93 // TODO(ldixon): Refactor parent NetworkInterface class so these are not | 93 // TODO(ldixon): Refactor parent NetworkInterface class so these are not |
| 94 // required. They are RTC specific and should be in an appropriate subclass. | 94 // required. They are RTC specific and should be in an appropriate subclass. |
| 95 virtual bool SendRtcp(rtc::Buffer* packet, | 95 virtual bool SendRtcp(rtc::Buffer* packet, |
| 96 rtc::DiffServCodePoint dscp) { | 96 const rtc::PacketOptions& options) { |
| 97 LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SendRtcp."; | 97 LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SendRtcp."; |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 virtual int SetOption(SocketType type, rtc::Socket::Option opt, | 100 virtual int SetOption(SocketType type, rtc::Socket::Option opt, |
| 101 int option) { | 101 int option) { |
| 102 LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SetOption."; | 102 LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SetOption."; |
| 103 return 0; | 103 return 0; |
| 104 } | 104 } |
| 105 virtual void SetDefaultDSCPCode(rtc::DiffServCodePoint dscp) { | 105 virtual void SetDefaultDSCPCode(rtc::DiffServCodePoint dscp) { |
| 106 LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SetOption."; | 106 LOG(LS_WARNING) << "Unsupported: SctpFakeNetworkInterface::SetOption."; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 // Channel 1 is gone now. | 526 // Channel 1 is gone now. |
| 527 | 527 |
| 528 // Create a new channel 1. | 528 // Create a new channel 1. |
| 529 AddStream(1); | 529 AddStream(1); |
| 530 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); | 530 ASSERT_TRUE(SendData(channel1(), 1, "hi?", &result)); |
| 531 EXPECT_EQ(cricket::SDR_SUCCESS, result); | 531 EXPECT_EQ(cricket::SDR_SUCCESS, result); |
| 532 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); | 532 EXPECT_TRUE_WAIT(ReceivedData(receiver2(), 1, "hi?"), 1000); |
| 533 channel1()->RemoveSendStream(1); | 533 channel1()->RemoveSendStream(1); |
| 534 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); | 534 EXPECT_TRUE_WAIT(chan_2_sig_receiver.StreamCloseCount(1) == 2, 1000); |
| 535 } | 535 } |
| OLD | NEW |