00001
00002
00003 #ifndef _HDHRSTREAMHANDLER_H_
00004 #define _HDHRSTREAMHANDLER_H_
00005
00006 #include <vector>
00007 using namespace std;
00008
00009 #include <QString>
00010 #include <QMutex>
00011 #include <QMap>
00012
00013 #include "mythmiscutil.h"
00014 #include "DeviceReadBuffer.h"
00015 #include "mpegstreamdata.h"
00016 #include "streamhandler.h"
00017 #include "dtvconfparserhelpers.h"
00018
00019 class HDHRStreamHandler;
00020 class DTVSignalMonitor;
00021 class HDHRChannel;
00022 class DeviceReadBuffer;
00023
00024
00025 #ifdef USING_HDHOMERUN
00026 #include "hdhomerun.h"
00027 #else
00028 struct hdhomerun_device_t { int dummy; };
00029 #endif
00030
00031 enum HDHRTuneMode {
00032 hdhrTuneModeNone = 0,
00033 hdhrTuneModeFrequency,
00034 hdhrTuneModeFrequencyPid,
00035 hdhrTuneModeFrequencyProgram,
00036 hdhrTuneModeVChannel
00037 };
00038
00039
00040
00041
00042
00043
00044
00045 class HDHRStreamHandler : public StreamHandler
00046 {
00047 public:
00048 static HDHRStreamHandler *Get(const QString &devicename);
00049 static void Return(HDHRStreamHandler * & ref);
00050
00051 virtual void AddListener(MPEGStreamData *data,
00052 bool allow_section_reader = false,
00053 bool needs_drb = false,
00054 QString output_file = QString())
00055 {
00056 StreamHandler::AddListener(data, false, false, output_file);
00057 }
00058
00059 void GetTunerStatus(struct hdhomerun_tuner_status_t *status);
00060 bool IsConnected(void) const;
00061 vector<DTVTunerType> GetTunerTypes(void) const { return _tuner_types; }
00062
00063
00064 bool TuneChannel(const QString &chanid);
00065 bool TuneProgram(uint mpeg_prog_num);
00066 bool TuneVChannel(const QString &vchn);
00067 bool EnterPowerSavingMode(void);
00068
00069 private:
00070 HDHRStreamHandler(const QString &);
00071
00072 bool Connect(void);
00073
00074 QString TunerGet(const QString &name,
00075 bool report_error_return = true,
00076 bool print_error = true) const;
00077 QString TunerSet(const QString &name, const QString &value,
00078 bool report_error_return = true,
00079 bool print_error = true);
00080
00081 bool Open(void);
00082 void Close(void);
00083
00084 virtual void run(void);
00085
00086 virtual bool UpdateFilters(void);
00087
00088 private:
00089 hdhomerun_device_t *_hdhomerun_device;
00090 int _tuner;
00091 vector<DTVTunerType> _tuner_types;
00092 HDHRTuneMode _tune_mode;
00093
00094 mutable QMutex _hdhr_lock;
00095
00096
00097 static QMutex _handlers_lock;
00098 static QMap<QString, HDHRStreamHandler*> _handlers;
00099 static QMap<QString, uint> _handlers_refcnt;
00100 };
00101
00102 #endif // _HDHRSTREAMHANDLER_H_