Switch to unified view

a b/sc2src/songcastreceiver.h
1
/* Copyright (C) 2018 J.F.Dockes
2
 *   This program is free software; you can redistribute it and/or modify
3
 *   it under the terms of the GNU General Public License as published by
4
 *   the Free Software Foundation; either version 2 of the License, or
5
 *   (at your option) any later version.
6
 *
7
 *   This program is distributed in the hope that it will be useful,
8
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 *   GNU General Public License for more details.
11
 *
12
 *   You should have received a copy of the GNU General Public License
13
 *   along with this program; if not, write to the
14
 *   Free Software Foundation, Inc.,
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
17
18
#ifdef WITH_OHBUILD
19
#include "Debug.h"
20
#include "OhmReceiver.h"
21
#else
22
#include <OpenHome/OhmReceiver.h>
23
#include <OpenHome/OhSongcast/Debug.h>
24
#endif
25
26
#include "audiodecoder.h"
27
#include "chrono.h"
28
#include "rcvqueue.h"
29
30
using namespace OpenHome;
31
using namespace OpenHome::Av;
32
33
class SongcastReceiver : public IOhmReceiverDriver, public IOhmMsgProcessor {
34
public:
35
   SongcastReceiver(AudioEater* eater, AudioEater::Context *ctxt);
36
   ~SongcastReceiver();
37
38
   virtual TBool IsConnected();
39
private:
40
   // IOhmReceiverDriver
41
   virtual void Add(OhmMsg& aMsg);
42
   virtual void Timestamp(OhmMsg& aMsg);
43
   virtual void Started();
44
   virtual void Connected();
45
   virtual void Playing();
46
   virtual void Disconnected();
47
   virtual void Stopped();
48
49
   // IOhmMsgProcessor
50
   virtual void Process(OhmMsgAudio& aMsg);
51
   virtual void Process(OhmMsgTrack& aMsg);
52
   virtual void Process(OhmMsgMetatext& aMsg);
53
54
private:
55
   // Debug, stats, etc while we get to understand the Songcast streams
56
   class Observer {
57
   public:
58
       TBool iReset;
59
       TUint iCount;
60
       TUint iFrame;
61
       int dumpfd;
62
       Chrono chron;
63
       Observer() : iReset(true), iCount(0), iFrame(0), dumpfd(-1) {
64
#if 0
65
           dumpfd = 
66
               open("/y/av/tmp/sc2dump", O_WRONLY|O_CREAT|O_TRUNC, 0666);
67
           if (dumpfd < 0) {
68
               LOGERR("SongcastReceiver::Open dump file failed\n");
69
           }
70
#endif
71
       }
72
73
       void reset() {
74
           iReset = true;
75
       }
76
77
       void process(OhmMsgAudio& aMsg);
78
   };
79
    Observer m_obs;
80
    AudioDecoder *m_decoder{nullptr};
81
    AudioEater *m_eater;
82
    TBool iConnected;
83
};