source: trunk/sources/thelib/src/protocols/udpprotocol.cpp @ 496

Revision 496, 2.3 KB checked in by shiretu, 11 months ago (diff)

-- relaxing the signals for play/pause/resume for the non RTMP streams
-- promoted GetDecodedBytesCount? to 64 bit value

Line 
1/*
2 *  Copyright (c) 2010,
3 *  Gavriloaie Eugen-Andrei (shiretu@gmail.com)
4 *
5 *  This file is part of crtmpserver.
6 *  crtmpserver is free software: you can redistribute it and/or modify
7 *  it under the terms of the GNU General Public License as published by
8 *  the Free Software Foundation, either version 3 of the License, or
9 *  (at your option) any later version.
10 *
11 *  crtmpserver is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 *  GNU General Public License for more details.
15 *
16 *  You should have received a copy of the GNU General Public License
17 *  along with crtmpserver.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21#include "protocols/udpprotocol.h"
22#include "netio/netio.h"
23
24UDPProtocol::UDPProtocol()
25: BaseProtocol(PT_UDP) {
26        _decodedBytesCount = 0;
27        _pCarrier = NULL;
28}
29
30UDPProtocol::~UDPProtocol() {
31        if (_pCarrier != NULL) {
32                IOHandler *pCarrier = _pCarrier;
33                _pCarrier = NULL;
34                pCarrier->SetProtocol(NULL);
35                delete pCarrier;
36        }
37}
38
39bool UDPProtocol::Initialize(Variant &parameters) {
40        return true;
41}
42
43IOHandler *UDPProtocol::GetIOHandler() {
44        return _pCarrier;
45}
46
47void UDPProtocol::SetIOHandler(IOHandler *pIOHandler) {
48        if (pIOHandler != NULL) {
49                if (pIOHandler->GetType() != IOHT_UDP_CARRIER) {
50                        ASSERT("This protocol accepts only UDP carrier");
51                }
52        }
53        _pCarrier = pIOHandler;
54}
55
56bool UDPProtocol::AllowFarProtocol(uint64_t type) {
57        WARN("This protocol doesn't accept any far protocol");
58        return false;
59}
60
61bool UDPProtocol::AllowNearProtocol(uint64_t type) {
62        return true;
63}
64
65IOBuffer * UDPProtocol::GetInputBuffer() {
66        return &_inputBuffer;
67}
68
69bool UDPProtocol::SignalInputData(int32_t recvAmount) {
70        ASSERT("Operation not supported");
71        return false;
72}
73
74bool UDPProtocol::SignalInputData(int32_t recvAmount, sockaddr_in *pPeerAddress) {
75        _decodedBytesCount += recvAmount;
76        return _pNearProtocol->SignalInputData(_inputBuffer, pPeerAddress);
77}
78
79bool UDPProtocol::SignalInputData(IOBuffer & /* ignored */) {
80        ASSERT("OPERATION NOT SUPPORTED");
81        return false;
82}
83
84bool UDPProtocol::EnqueueForOutbound() {
85        if (_pCarrier == NULL) {
86                ASSERT("TCPProtocol has no carrier");
87                return false;
88        }
89        return _pCarrier->SignalOutputData();
90}
91
92uint64_t UDPProtocol::GetDecodedBytesCount() {
93        return _decodedBytesCount;
94}
95
96
Note: See TracBrowser for help on using the repository browser.