131
131
{ 'a', "app", Arg_parser::yes },
132
132
{ 'p', "path", Arg_parser::yes },
133
133
{ 'f', "filename", Arg_parser::yes },
134
{ 't', "tcurl", Arg_parser::yes },
135
{ 's', "swfurl", Arg_parser::yes },
134
{ 't', "tcurl", Arg_parser::yes },
135
{ 's', "swfurl", Arg_parser::yes },
136
136
{ 'u', "url", Arg_parser::yes },
137
137
{ 'n', "netdebug", Arg_parser::no }
152
152
dbglogfile.setVerbosity(rcfile.verbosityLevel());
155
156
string app; // the application name
156
157
string path; // the path to the file on the server
157
158
string tcUrl; // the tcUrl field
158
159
string swfUrl; // the swfUrl field
159
160
string filename; // the filename to play
161
163
// Handle command line arguments
162
164
for( int i = 0; i < parser.arguments(); ++i ) {
163
165
const int code = parser.code(i);
216
218
return EXIT_FAILURE;
221
string protocol; // the network protocol, rtmp or http
222
string query; // any queries for the host
223
string pageUrl; // the pageUrl field
224
string hostname; // the hostname of the server
226
URL url( infiles[0] );
229
221
// Trap ^C (SIGINT) so we can kill all the threads
230
222
act.sa_handler = cntrlc_handler;
231
223
sigaction (SIGINT, &act, NULL);
233
protocol = url.protocol();
234
hostname = url.hostname();
235
log_debug("hostname: %s", hostname);
236
portstr = url.port();
237
query = url.querystring();
239
if ( portstr.empty() )
241
if ((protocol == "http") || (protocol == "rtmpt")) {
244
if (protocol == "rtmp") {
250
port = strtol(portstr.c_str(), NULL, 0) & 0xffff;
259
if ( filename.empty() )
261
string::size_type end = path.rfind('/');
262
if (end != string::npos) {
263
filename = path.substr(end + 1);
269
tcUrl = protocol + "://" + hostname;
270
if (!portstr.empty()) {
271
tcUrl += ":" + portstr;
273
if (!query.empty()) {
274
tcUrl += "/" + query;
283
// Get the application name
284
// rtmp://localhost/application/resource
285
// ^^^^^^^^^^^ <-- appname is this
288
if ( ! filename.empty() )
290
string::size_type end = app.rfind(filename);
291
if (end != string::npos) {
292
app = app.substr(0, end);
297
string::size_type end = app.find_first_not_of('/');
298
if (end != string::npos) {
299
app = app.substr(end);
301
end = app.find_last_not_of('/');
302
if (end != string::npos) {
303
app = app.substr(0, end+1);
306
if (!query.empty()) {
312
if (swfUrl.empty()) {
313
swfUrl = "mediaplayer.swf";
315
if (pageUrl.empty()) {
316
pageUrl = "http://gnashdev.org";
319
log_debug("URL is %s", url);
320
log_debug("Protocol is %s", protocol);
321
log_debug("Host is %s", hostname);
322
log_debug("Port is %s", port);
323
log_debug("Path is %s", path);
324
log_debug("Filename is %s", filename);
325
log_debug("App is %s", app);
326
log_debug("Query is %s", query);
327
log_debug("tcUrl is %s", tcUrl);
328
log_debug("swfUrl is %s", swfUrl);
329
log_debug("pageUrl is %s", pageUrl);
331
226
client.toggleDebug(netdebug);
332
227
if (client.createClient(hostname, port) == false) {
333
228
log_error("Can't connect to RTMP server %s", hostname);
337
if ( ! client.handShakeRequest() )
232
if (! client.handShakeRequest()) {
339
233
log_error("RTMP handshake request failed");
340
234
exit(EXIT_FAILURE);
343
if ( ! client.clientFinish() )
237
if (! client.clientFinish()) {
345
238
log_error("RTMP handshake completion failed");
346
239
exit(EXIT_FAILURE);
351
244
// RTMP::rtmp_head_t *rthead = 0;
353
246
log_debug("Sending NetConnection Connect message,");
354
BufferSharedPtr buf2 = client.encodeConnect(app.c_str(), swfUrl.c_str(), tcUrl.c_str(), 615, 124, 1, pageUrl.c_str());
248
BufferSharedPtr buf2 = client.encodeConnect(app.c_str(), swfUrl.c_str(), tcUrl.c_str(), RTMPClient::DEFAULT_AUDIO_SET,
249
RTMPClient::DEFAULT_VIDEO_SET,
250
RTMPClient::SEEK, pageUrl.c_str());
252
BufferSharedPtr buf2 = client.encodeConnect(infiles[0]);
355
254
// BufferSharedPtr buf2 = client.encodeConnect("video/2006/sekt/gate06/tablan_valentin", "mediaplayer.swf", "rtmp://velblod.videolectures.net/video/2006/sekt/gate06/tablan_valentin", 615, 124, 1, "http://gnashdev.org");
356
255
// BufferSharedPtr buf2 = client.encodeConnect("oflaDemo", "http://192.168.1.70/software/gnash/tests/ofla_demo.swf", "rtmp://localhost/oflaDemo/stream", 615, 124, 1, "http://192.168.1.70/software/gnash/tests/index.html");
357
256
//buf2->resize(buf2->size() - 6); // FIXME: encodeConnect returns the wrong size for the buffer!