Changeset 54
Legend:
- Unmodified
- Added
- Removed
-
trunk/builders/cmake/rtmpserver/rtmpserver.lua
r53 r54 133 133 ip="0.0.0.0", 134 134 port=6666, 135 protocol="inboundLiveFlv" 135 protocol="inboundLiveFlv", 136 waitForMetadata=true, 136 137 }, 137 138 { -
trunk/sources/thelib/include/protocols/liveflv/inboundliveflvprotocol.h
r2 r54 31 31 InNetLiveFLVStream *_pStream; 32 32 bool _headerParsed; 33 bool _waitForMetadata; 33 34 public: 34 35 InboundLiveFLVProtocol(); … … 41 42 virtual bool SignalInputData(IOBuffer &buffer); 42 43 private: 43 bool InitializeStream( );44 bool InitializeStream(string streamName); 44 45 }; 45 46 -
trunk/sources/thelib/src/protocols/liveflv/inboundliveflvprotocol.cpp
r2 r54 1 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 modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (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 of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 * 16 * You should have received a copy of the GNU General Public License17 * along with crtmpserver. If not, see <http://www.gnu.org/licenses/>.18 */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 19 20 20 #ifdef HAS_PROTOCOL_LIVEFLV … … 32 32 _pStream = NULL; 33 33 _headerParsed = false; 34 _waitForMetadata = false; 34 35 } 35 36 … … 42 43 43 44 bool InboundLiveFLVProtocol::Initialize(Variant ¶meters) { 45 GetCustomParameters() = parameters; 46 FINEST("parameters:\n%s", STR(parameters.ToString())); 47 if (parameters.HasKey("waitForMetadata")) 48 _waitForMetadata = (bool)parameters["waitForMetadata"]; 49 else 50 _waitForMetadata = false; 51 FINEST("_waitForMetadata: %d", _waitForMetadata); 44 52 return true; 45 53 } … … 63 71 //1. Initialize the stream 64 72 if (_pStream == NULL) { 65 if (!InitializeStream()) { 66 FATAL("Unable to initialize the stream"); 67 return false; 73 if (!_waitForMetadata) { 74 if (!InitializeStream("")) { 75 FATAL("Unable to initialize the stream"); 76 return false; 77 } 68 78 } 69 79 } … … 113 123 { 114 124 //audio data 115 if (!_pStream->FeedData(GETIBPOINTER(buffer), length, 0, 116 length, timestamp, true)) { 117 FATAL("Unable to feed audio"); 118 return false; 125 if (_pStream != NULL) { 126 if (!_pStream->FeedData(GETIBPOINTER(buffer), length, 0, 127 length, timestamp, true)) { 128 FATAL("Unable to feed audio"); 129 return false; 130 } 119 131 } 120 132 break; … … 123 135 { 124 136 //video data 125 if (!_pStream->FeedData(GETIBPOINTER(buffer), length, 0, 126 length, timestamp, false)) { 127 FATAL("Unable to feed audio"); 128 return false; 137 if (_pStream != NULL) { 138 if (!_pStream->FeedData(GETIBPOINTER(buffer), length, 0, 139 length, timestamp, false)) { 140 FATAL("Unable to feed audio"); 141 return false; 142 } 129 143 } 130 144 break; … … 151 165 //3. Read the rest of the parameters 152 166 Variant parameters; 167 string streamName = ""; 153 168 while (GETAVAILABLEBYTESCOUNT(metaBuffer) > 0) { 154 169 Variant v; … … 157 172 return false; 158 173 } 174 if (v.HasKey("streamName")) { 175 if (v["streamName"] == V_STRING) { 176 streamName = (string) v["streamName"]; 177 } 178 } 159 179 parameters.PushToArray(v); 160 180 } 161 181 182 if (_pStream == NULL) { 183 if (!InitializeStream(streamName)) { 184 FATAL("Unable to initialize the stream"); 185 return false; 186 } 187 } 188 189 INFO("Stream metadata:\n%s", STR(parameters.ToString())); 190 162 191 //4. Send the notify 163 if (!_pStream->SendStreamMessage(notifyFunction, parameters, true)) { 164 FATAL("Unable to send the notify"); 165 return false; 192 if (_pStream != NULL) { 193 if (!_pStream->SendStreamMessage(notifyFunction, parameters, true)) { 194 FATAL("Unable to send the notify"); 195 return false; 196 } 166 197 } 167 198 … … 183 214 } 184 215 185 bool InboundLiveFLVProtocol::InitializeStream() { 186 //1. Compute a stream name based on the nature of the carrier (if any...) 187 string streamName = ""; 188 if (GetIOHandler() != NULL) { 189 //we have a carrier 190 if (GetIOHandler()->GetType() == IOHT_TCP_CARRIER) { 191 //this is a tcp carrier 192 streamName = format("%s_%d", 193 STR(((TCPCarrier *) GetIOHandler())->GetFarEndpointAddressIp()), 194 ((TCPCarrier *) GetIOHandler())->GetFarEndpointPort()); 216 bool InboundLiveFLVProtocol::InitializeStream(string streamName) { 217 if (streamName == "") { 218 //1. Compute a stream name based on the nature of the carrier (if any...) 219 if (GetIOHandler() != NULL) { 220 //we have a carrier 221 if (GetIOHandler()->GetType() == IOHT_TCP_CARRIER) { 222 //this is a tcp carrier 223 streamName = format("%s_%d", 224 STR(((TCPCarrier *) GetIOHandler())->GetFarEndpointAddressIp()), 225 ((TCPCarrier *) GetIOHandler())->GetFarEndpointPort()); 226 } else { 227 //this is not a TCP carrier 228 streamName = format("flv_%d", GetId()); 229 } 195 230 } else { 196 // this is not a TCP carrier231 //we don't have a carrier. This protocl might be artificially fed 197 232 streamName = format("flv_%d", GetId()); 198 233 } 199 } else {200 //we don't have a carrier. This protocl might be artificially fed201 streamName = format("flv_%d", GetId());202 234 } 203 235 FINEST("Stream name: %s", STR(streamName));
Note: See TracChangeset
for help on using the changeset viewer.
