Switch to unified view

a/mpd2src/mpd2sc.cpp b/mpd2src/mpd2sc.cpp
...
...
41
#include <OpenHome/Private/Debug.h>
41
#include <OpenHome/Private/Debug.h>
42
#include <OpenHome/Os.h>
42
#include <OpenHome/Os.h>
43
#include <OpenHome/Private/Env.h>
43
#include <OpenHome/Private/Env.h>
44
44
45
#include <cstring>
45
#include <cstring>
46
#include <fstream>
47
#include <iostream>
46
#include <vector>
48
#include <vector>
47
#include <stdio.h>
49
#include <stdio.h>
48
#include <unistd.h>
50
#include <unistd.h>
49
#include <signal.h>
51
#include <signal.h>
50
#include <sys/socket.h>
52
#include <sys/socket.h>
...
...
477
"  -c, --channel, [0..65535] sender channel.\n"
479
"  -c, --channel, [0..65535] sender channel.\n"
478
"  -d, --disabled, [disabled] start up disabled.\n"
480
"  -d, --disabled, [disabled] start up disabled.\n"
479
"  -f, --file, [file] file name to read and send.\n"
481
"  -f, --file, [file] file name to read and send.\n"
480
"      Use xx.wav for an actual wav,\n"
482
"      Use xx.wav for an actual wav,\n"
481
"      xx or xx.fifo for a fifo, stdin for stdin.\n"
483
"      xx or xx.fifo for a fifo, stdin for stdin.\n"
484
"  -o, --output, [output] file name to write uri and metadata.\n"
482
"  -l, --latency, [latency] latency in ms.\n"
485
"  -l, --latency, [latency] latency in ms.\n"
483
"  -m, --multicast, [multicast] use multicast instead of unicast.\n"
486
"  -m, --multicast, [multicast] use multicast instead of unicast.\n"
484
"  -p, --pace, Use internal timer to pace source. Implicit for regular files.\n"
487
"  -p, --pace, Use internal timer to pace source. Implicit for regular files.\n"
485
"  -n, --name, [name] name of the sender.\n"
488
"  -n, --name, [name] name of the sender.\n"
486
"  -t, --ttl, [ttl] ttl.\n"
489
"  -t, --ttl, [ttl] ttl.\n"
...
...
511
    {"audio", required_argument, 0, 'A'},
514
    {"audio", required_argument, 0, 'A'},
512
    {"adapter", required_argument, 0, 'a'},
515
    {"adapter", required_argument, 0, 'a'},
513
    {"channel", required_argument, 0, 'c'},
516
    {"channel", required_argument, 0, 'c'},
514
    {"disabled", 0, 0, 'd'},
517
    {"disabled", 0, 0, 'd'},
515
    {"file", required_argument, 0, 'f'},
518
    {"file", required_argument, 0, 'f'},
519
    {"output", required_argument, 0, 'o'},
516
    {"latency", required_argument, 0, 'l'},
520
    {"latency", required_argument, 0, 'l'},
517
    {"multicast", 0, 0, 'm'},
521
    {"multicast", 0, 0, 'm'},
518
    {"name", required_argument, 0, 'n'},
522
    {"name", required_argument, 0, 'n'},
519
    {"pace", 0, 0, 'p'},
523
    {"pace", 0, 0, 'p'},
520
    {"ttl", required_argument, 0, 't'},
524
    {"ttl", required_argument, 0, 't'},
...
...
526
{
530
{
527
    thisprog = argv[0];
531
    thisprog = argv[0];
528
    int ret;
532
    int ret;
529
    (void)op_flags;
533
    (void)op_flags;
530
    string audioparams, sfile, sname("Openhome WavSender"), sudn("12345678");
534
    string audioparams, sfile, sname("Openhome WavSender"), sudn("12345678");
535
    string ofile;
531
    unsigned int adaptidx(0), channel(0), ttl(1), latency(100);
536
    unsigned int adaptidx(0), channel(0), ttl(1), latency(100);
532
    while ((ret = getopt_long(argc, argv, "A:a:c:df:l:mn:pt:u:",
537
    while ((ret = getopt_long(argc, argv, "A:a:c:df:o:l:mn:pt:u:",
533
                              long_options, NULL)) != -1) {
538
                              long_options, NULL)) != -1) {
534
        switch (ret) {
539
        switch (ret) {
535
        case 'A': audioparams = optarg;op_flags |= OPT_A; break;
540
        case 'A': audioparams = optarg;op_flags |= OPT_A; break;
536
        case 'a': adaptidx = atoi(optarg);op_flags |= OPT_a; break;
541
        case 'a': adaptidx = atoi(optarg);op_flags |= OPT_a; break;
537
        case 'c': channel = atoi(optarg);op_flags |= OPT_c; break;
542
        case 'c': channel = atoi(optarg);op_flags |= OPT_c; break;
538
        case 'd': op_flags |= OPT_d; break;
543
        case 'd': op_flags |= OPT_d; break;
539
        case 'f': sfile = optarg;op_flags |= OPT_f; break;
544
        case 'f': sfile = optarg;op_flags |= OPT_f; break;
545
        case 'o': ofile = optarg; break;
540
        case 'h': Usage(stdout);break;
546
        case 'h': Usage(stdout);break;
541
        case 'l': latency = atoi(optarg); op_flags |= OPT_l; break;
547
        case 'l': latency = atoi(optarg); op_flags |= OPT_l; break;
542
        case 'm': op_flags |= OPT_m; break;
548
        case 'm': op_flags |= OPT_m; break;
543
        case 'n': sname = optarg;op_flags |= OPT_n; break;
549
        case 'n': sname = optarg;op_flags |= OPT_n; break;
544
        case 'p': op_flags |= OPT_p; break;
550
        case 'p': op_flags |= OPT_p; break;
...
...
628
634
629
    const Brx& suri(sender->SenderUri());
635
    const Brx& suri(sender->SenderUri());
630
    string uri((const char*)suri.Ptr(), suri.Bytes());
636
    string uri((const char*)suri.Ptr(), suri.Bytes());
631
    const Brx& smeta(sender->SenderMetadata());
637
    const Brx& smeta(sender->SenderMetadata());
632
    string meta((const char*)smeta.Ptr(), smeta.Bytes());
638
    string meta((const char*)smeta.Ptr(), smeta.Bytes());
639
640
    ostream* fp = &cout;
641
    ofstream fout;
642
    if (!ofile.empty()) {
643
        fout.open(ofile);
644
        fp = &fout;
645
    }
633
    cout << "URI " << UPnPP::base64_encode(uri) <<
646
    *fp << "URI " << UPnPP::base64_encode(uri) <<
634
        " METADATA " << UPnPP::base64_encode(meta) << endl;
647
        " METADATA " << UPnPP::base64_encode(meta) << endl << flush;
635
//    cout << "URI " << uri << " METADATA " << meta << endl;
636
    cout.flush();
637
648
638
    signal(SIGUSR1, sigcatcher);
649
    signal(SIGUSR1, sigcatcher);
639
    signal(SIGINT, sigcatcher);
650
    signal(SIGINT, sigcatcher);
640
    signal(SIGTERM, sigcatcher);
651
    signal(SIGTERM, sigcatcher);
641
    if (pcmsender->Start(!disabled)) {
652
    if (pcmsender->Start(!disabled)) {