| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 | 576 |
| 577 void BaseSession::SetState(State state) { | 577 void BaseSession::SetState(State state) { |
| 578 ASSERT(signaling_thread_->IsCurrent()); | 578 ASSERT(signaling_thread_->IsCurrent()); |
| 579 if (state != state_) { | 579 if (state != state_) { |
| 580 LogState(state_, state); | 580 LogState(state_, state); |
| 581 state_ = state; | 581 state_ = state; |
| 582 SignalState(this, state_); | 582 SignalState(this, state_); |
| 583 signaling_thread_->Post(this, MSG_STATE); | 583 signaling_thread_->Post(this, MSG_STATE); |
| 584 } | 584 } |
| 585 SignalNewDescription(); | |
| 586 } | 585 } |
| 587 | 586 |
| 588 void BaseSession::SetError(Error error, const std::string& error_desc) { | 587 void BaseSession::SetError(Error error, const std::string& error_desc) { |
| 589 ASSERT(signaling_thread_->IsCurrent()); | 588 ASSERT(signaling_thread_->IsCurrent()); |
| 590 if (error != error_) { | 589 if (error != error_) { |
| 591 error_ = error; | 590 error_ = error; |
| 592 error_desc_ = error_desc; | 591 error_desc_ = error_desc; |
| 593 SignalError(this, error); | 592 SignalError(this, error); |
| 594 } | 593 } |
| 595 } | 594 } |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 } | 779 } |
| 781 const TransportInfo* transport_info = | 780 const TransportInfo* transport_info = |
| 782 description->GetTransportInfoByName(content_name); | 781 description->GetTransportInfoByName(content_name); |
| 783 if (!transport_info) { | 782 if (!transport_info) { |
| 784 return false; | 783 return false; |
| 785 } | 784 } |
| 786 *tdesc = transport_info->description; | 785 *tdesc = transport_info->description; |
| 787 return true; | 786 return true; |
| 788 } | 787 } |
| 789 | 788 |
| 790 void BaseSession::SignalNewDescription() { | |
| 791 ContentAction action; | |
| 792 ContentSource source; | |
| 793 if (!GetContentAction(&action, &source)) { | |
| 794 return; | |
| 795 } | |
| 796 if (source == CS_LOCAL) { | |
| 797 SignalNewLocalDescription(this, action); | |
| 798 } else { | |
| 799 SignalNewRemoteDescription(this, action); | |
| 800 } | |
| 801 } | |
| 802 | |
| 803 bool BaseSession::GetContentAction(ContentAction* action, | |
| 804 ContentSource* source) { | |
| 805 switch (state_) { | |
| 806 // new local description | |
| 807 case STATE_SENTINITIATE: | |
| 808 *action = CA_OFFER; | |
| 809 *source = CS_LOCAL; | |
| 810 break; | |
| 811 case STATE_SENTPRACCEPT: | |
| 812 *action = CA_PRANSWER; | |
| 813 *source = CS_LOCAL; | |
| 814 break; | |
| 815 case STATE_SENTACCEPT: | |
| 816 *action = CA_ANSWER; | |
| 817 *source = CS_LOCAL; | |
| 818 break; | |
| 819 // new remote description | |
| 820 case STATE_RECEIVEDINITIATE: | |
| 821 *action = CA_OFFER; | |
| 822 *source = CS_REMOTE; | |
| 823 break; | |
| 824 case STATE_RECEIVEDPRACCEPT: | |
| 825 *action = CA_PRANSWER; | |
| 826 *source = CS_REMOTE; | |
| 827 break; | |
| 828 case STATE_RECEIVEDACCEPT: | |
| 829 *action = CA_ANSWER; | |
| 830 *source = CS_REMOTE; | |
| 831 break; | |
| 832 default: | |
| 833 return false; | |
| 834 } | |
| 835 return true; | |
| 836 } | |
| 837 | |
| 838 void BaseSession::OnMessage(rtc::Message *pmsg) { | 789 void BaseSession::OnMessage(rtc::Message *pmsg) { |
| 839 switch (pmsg->message_id) { | 790 switch (pmsg->message_id) { |
| 840 case MSG_TIMEOUT: | 791 case MSG_TIMEOUT: |
| 841 // Session timeout has occured. | 792 // Session timeout has occured. |
| 842 SetError(ERROR_TIME, "Session timeout has occured."); | 793 SetError(ERROR_TIME, "Session timeout has occured."); |
| 843 break; | 794 break; |
| 844 | 795 |
| 845 case MSG_STATE: | 796 case MSG_STATE: |
| 846 switch (state_) { | 797 switch (state_) { |
| 847 case STATE_SENTACCEPT: | 798 case STATE_SENTACCEPT: |
| 848 case STATE_RECEIVEDACCEPT: | 799 case STATE_RECEIVEDACCEPT: |
| 849 SetState(STATE_INPROGRESS); | 800 SetState(STATE_INPROGRESS); |
| 850 break; | 801 break; |
| 851 | 802 |
| 852 default: | 803 default: |
| 853 // Explicitly ignoring some states here. | 804 // Explicitly ignoring some states here. |
| 854 break; | 805 break; |
| 855 } | 806 } |
| 856 break; | 807 break; |
| 857 } | 808 } |
| 858 } | 809 } |
| 859 | 810 |
| 860 } // namespace cricket | 811 } // namespace cricket |
| OLD | NEW |