#endif\r
}\r
\r
-#define RaymCriticalSection(OBJ, BLOCK) RaymLock(OBJ); BLOCK; RaymUnlock(OBJ);\r
+//#define RaymCriticalSection(OBJ, BLOCK) RaymLock(OBJ); BLOCK; RaymUnlock(OBJ);\r
\r
} // Raym\r
\r
#pragma once\r
\r
\r
-#include <Raym/Raym.h>\r
+#include "Raym/Raym.h"\r
\r
#include "keys.h"\r
#include "ry0/device/TunerFactory.h"\r
\r
HTTPD::HTTPD()\r
{\r
- _controller = NULL;\r
- _httpd = NULL;\r
- _port = -1;\r
- _path = NULL;\r
+ _controller = NULL;\r
+ _tuner_count = -1;\r
+ _tuners = NULL;\r
+ _httpd = NULL;\r
+ _port = -1;\r
+ _path = NULL;\r
}\r
\r
HTTPD::~HTTPD()\r
{\r
RELEASE(_httpd);\r
RELEASE(_path);\r
-\r
- _controller = NULL;\r
}\r
\r
HTTPD *HTTPD::alloc()\r
\r
HTTPD *HTTPD::initWithController(Controller *controller, int port, String *path)\r
{\r
- _controller = controller;\r
- _port = port;\r
- _path = path->retain();\r
+ _controller = controller;\r
+ _tuner_count = controller->_tunerCount;\r
+ _tuners = controller->_tuners;\r
+\r
+ _port = port;\r
+ _path = path->retain();\r
\r
return this;\r
}\r
DebugLog0("request: %s\n", uri->cString());\r
if (uri->isMatch("^/config.xml$"))\r
{\r
- RaymCriticalSection(_controller,\r
- {\r
- response = responseWithDictionary(request, _controller->_props);\r
- });\r
+ RaymLock(_controller);\r
+ response = responseWithDictionary(request, _controller->_props);\r
+ RaymUnlock(_controller);\r
}\r
else if (uri->isMatch("^/status.xml$"))\r
{\r
- RaymCriticalSection(_controller,\r
- {\r
- response = responseWithDictionary(request, _controller->_status);\r
- });\r
+ RaymLock(_controller);\r
+ response = responseWithDictionary(request, _controller->_status);\r
+ RaymUnlock(_controller);\r
}\r
//\r
// tuner control\r
// String::substringWithRange() の実装は後回しなので。。\r
std::string s = uri->cString();\r
int tuner = atoi(s.substr(1, 3).c_str());\r
- if ((0 <= tuner) && (tuner < _controller->_tunerCount))\r
+ if ((0 <= tuner) && (tuner < _tuner_count))\r
{\r
response = requestTunerControl(request, client, tuner);\r
}\r
}\r
else\r
{\r
- channel = _controller->_tuners[tuner]->channel();\r
+ channel = _tuners[tuner]->channel();\r
}\r
\r
if (channel >= 0)\r
}\r
dst_addr.sin_port = htons(p_udp->intValue());\r
\r
- if (_controller->_tuners[tuner]->startStreaming(&dst_addr))\r
+ if (_tuners[tuner]->startStreaming(&dst_addr))\r
{\r
// success\r
DebugLog2("success.\n");\r
{\r
}\r
\r
- _controller->_tuners[tuner]->stopStreaming();\r
+ _tuners[tuner]->stopStreaming();\r
\r
// success\r
DebugLog2("success.\n");\r
#pragma once\r
\r
#include "Raym/Raym.h"\r
+#include "ry0/device/Tuner.h"\r
#include "net/HTTPDaemon.h"\r
\r
namespace ry0\r
public NET::HTTPDaemonDelegate\r
{\r
private:\r
- Controller * _controller;\r
- NET::HTTPDaemon * _httpd;\r
- int _port;\r
- Raym::String * _path;\r
+ Controller * _controller;\r
+ int _tuner_count;\r
+ ry0::device::Tuner ** _tuners;\r
+\r
+ NET::HTTPDaemon * _httpd;\r
+ int _port;\r
+ Raym::String * _path;\r
\r
protected:\r
HTTPD();\r
Reservation::Reservation()\r
{\r
_controller = NULL;\r
+ _tuner_count = -1;\r
+ _tuners = NULL;\r
_reservations_path = NULL;\r
_reservations = NULL;\r
_reservation_seq_id = -1;\r
\r
Reservation::~Reservation()\r
{\r
- _controller = NULL;\r
RELEASE(_reservations_path);\r
RELEASE(_reservations);\r
}\r
\r
Reservation *Reservation::initWithController(Controller *controller)\r
{\r
- _controller = controller;\r
+ _controller = controller;\r
+ _tuner_count = controller->_tunerCount;\r
+ _tuners = controller->_tuners;\r
\r
_reservations_path = String::alloc()->initWithFormat("%s%s.iptd.reservations.plist", _controller->_system_path->cString(), Controller::_plist_prefix);\r
if (_reservations_path == NULL)\r
{\r
DebugLog1("reservations file: \"%s\"", _reservations_path->cString());\r
\r
- // 予約情報シーケンスID\r
_reservation_seq_id = _reservations->integerForKey(KEY_EPG_LAST_RESV_ID);\r
}\r
\r
- // 周期タイマ起動\r
_timer_periodic = Timer::alloc()->initWithTimeInterval(1.0, this, NULL, true);\r
if (_timer_periodic == NULL)\r
{\r
// 現在時刻取得\r
time_t now = time(NULL);\r
\r
- for (int tuner = 0; tuner < _controller->_tunerCount; ++tuner)\r
+ for (int tuner = 0; tuner < _tuner_count; ++tuner)\r
{\r
- Array *array = _reservations->arrayForKey(_controller->_tuners[tuner]->name());\r
+ Array *array = _reservations->arrayForKey(_tuners[tuner]->name());\r
if ((array == NULL) || (array->count() == 0))\r
{\r
// next tuner\r
// lock\r
RaymLock(_controller);\r
\r
- while ((0 <= tuner) && (tuner < _controller->_tunerCount) && (in_epg != NULL))\r
+ while ((0 <= tuner) && (tuner < _tuner_count) && (in_epg != NULL))\r
{\r
Dictionary *epg = Dictionary::dictionaryWithDictionary(in_epg);\r
if (epg == NULL)\r
break;\r
}\r
\r
- Array *array = _reservations->arrayForKey(_controller->_tuners[tuner]->name());\r
+ Array *array = _reservations->arrayForKey(_tuners[tuner]->name());\r
if (array == NULL)\r
{\r
array = Array::arrayWithCapacity(0);\r
- _reservations->setObject(array, _controller->_tuners[tuner]->name());\r
+ _reservations->setObject(array, _tuners[tuner]->name());\r
}\r
\r
time_t epg_start;\r
RaymLock(_controller);\r
\r
//\r
- if ((0 <= tuner) && (tuner < _controller->_tunerCount))\r
+ if ((0 <= tuner) && (tuner < _tuner_count))\r
{\r
- Array *array = _reservations->arrayForKey(_controller->_tuners[tuner]->name());\r
+ Array *array = _reservations->arrayForKey(_tuners[tuner]->name());\r
if (array != NULL)\r
{\r
if (array->count() > 0)\r
//\r
else if ((tuner < 0) && (0 <= reserve_id) && (reserve_id < 1000000))\r
{\r
- for (int i = 0; i < _controller->_tunerCount; ++i)\r
+ for (int i = 0; i < _tuner_count; ++i)\r
{\r
- Array *array = _reservations->arrayForKey(_controller->_tuners[i]->name());\r
+ Array *array = _reservations->arrayForKey(_tuners[i]->name());\r
if (array != NULL)\r
{\r
for (uint j = 0; j < array->count(); ++j)\r
if (sprintf_s(tmp, sizeof(tmp),\r
"\\%04d%02d%02d_%02d%02d%02d_%03d_%s.ts",\r
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,\r
- _controller->_tuners[tuner]->channel(), _controller->_tuners[tuner]->name()) < 0)\r
+ _tuners[tuner]->channel(), _tuners[tuner]->name()) < 0)\r
{\r
DebugLog0("sprintf_s() error: filename");\r
result = "";\r
DebugLog2("periodic: %d", now);\r
\r
//\r
- for (int tuner = 0; tuner < _controller->_tunerCount; ++tuner)\r
+ for (int tuner = 0; tuner < _tuner_count; ++tuner)\r
{\r
- Array *array = _reservations->arrayForKey(_controller->_tuners[tuner]->name());\r
+ Array *array = _reservations->arrayForKey(_tuners[tuner]->name());\r
if ((array == NULL) || (array->count() == 0))\r
{\r
// next tuner\r
if (stop_need)\r
{\r
DebugLog2("I try stop\n");\r
- int fd = _controller->_tuners[tuner]->stopRecording();\r
+ int fd = _tuners[tuner]->stopRecording();\r
if (fd < 0)\r
{\r
DebugLog1("stopRecording() error.\n");\r
else\r
{\r
DebugLog2("stopRecording() ok\n");\r
- DebugLog0("stop recording of \"%s\"", _controller->_tuners[tuner]->name());\r
+ DebugLog0("stop recording of \"%s\"", _tuners[tuner]->name());\r
_close(fd);\r
}\r
array->removeObject(epg);\r
{\r
DebugLog2("open ok.\n");\r
bool startResult = true;\r
- if (_controller->_tuners[tuner]->channel() != channel)\r
+ if (_tuners[tuner]->channel() != channel)\r
{\r
if (!_controller->setChannel(tuner, channel))\r
{\r
\r
if (startResult)\r
{\r
- if (_controller->_tuners[tuner]->startRecording(fd))\r
+ if (_tuners[tuner]->startRecording(fd))\r
{\r
DebugLog2("startRecording() ok.");\r
- DebugLog0("start recording of \"%s\" to %s.", _controller->_tuners[tuner]->name(), videopath.c_str());\r
+ DebugLog0("start recording of \"%s\" to %s.", _tuners[tuner]->name(), videopath.c_str());\r
}\r
else\r
{\r
\r
#pragma once\r
\r
-#include <Raym/Raym.h>\r
+#include "Raym/Raym.h"\r
+#include "ry0/device/Tuner.h"\r
\r
namespace ry0\r
{\r
\r
class Reservation : public Raym::Object,\r
public Raym::TimerDelegate\r
-\r
{\r
private:\r
- Controller * _controller;\r
- Raym::String * _reservations_path;\r
- Raym::Dictionary * _reservations; // 予約情報\r
- int _reservation_seq_id; // 予約情報シーケンスID\r
- Raym::Timer * _timer_periodic;\r
+ Controller * _controller;\r
+ int _tuner_count;\r
+ ry0::device::Tuner ** _tuners;\r
+\r
+ Raym::String * _reservations_path;\r
+ Raym::Dictionary * _reservations;\r
+ int _reservation_seq_id;\r
+ Raym::Timer * _timer_periodic;\r
\r
\r
protected:\r
DebugLog2("%s", __FUNCTION__);\r
\r
_controller = NULL;\r
+ _tuner_count = -1;\r
+ _tuners = NULL;\r
_ctrls = NULL;\r
_timer_periodic = NULL;\r
}\r
\r
Streaming *Streaming::initWithController(Controller *controller)\r
{\r
- _controller = controller;\r
+ _controller = controller;\r
+ _tuner_count = controller->_tunerCount;\r
+ _tuners = controller->_tuners;\r
\r
// 制御情報\r
_ctrls = Dictionary::alloc()->initWithCapacity(0);\r
tuner_channel_to_udp->setString(port_str, tuner_and_channel);\r
}\r
\r
-void Streaming::timerExpired(Timer *timer, void *userInfo)\r
+void Streaming::timerExpired(Timer *timer, void *user_info)\r
{\r
DebugLog2("%s", __FUNCTION__);\r
\r
\r
DebugLog0("auto streaming stop: %s", ((String *)using_ports->objectAtIndex(i))->cString());\r
\r
- _controller->_tuners[tuner]->stopStreaming();\r
+ _tuners[tuner]->stopStreaming();\r
using_port->removeObjectForKey((String *)using_ports->objectAtIndex(i));\r
}\r
}\r
EnterCriticalSection(&_cs);\r
\r
// 非ストリーミング中 かつ 非レコーディング中 または チャンネルが同じ 場合\r
- if (!_controller->_tuners[tuner]->isStreaming() && (!_controller->_tuners[tuner]->isRecording() || _controller->_tuners[tuner]->channel() == channel))\r
+ if (!_tuners[tuner]->isStreaming() && (!_tuners[tuner]->isRecording() || _tuners[tuner]->channel() == channel))\r
{\r
// ストリーミング開始可能\r
\r
- if (_controller->_tuners[tuner]->channel() != channel)\r
+ if (_tuners[tuner]->channel() != channel)\r
{\r
_controller->setChannel(tuner, channel);\r
}\r
dst_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);\r
dst_addr.sin_port = (WORD)udptable->table[i].dwLocalPort;\r
\r
- if (_controller->_tuners[tuner]->startStreaming(&dst_addr))\r
+ if (_tuners[tuner]->startStreaming(&dst_addr))\r
{\r
// 成功\r
DebugLog0("auto streaming start: %d", ntohs((WORD)udptable->table[i].dwLocalPort));\r
\r
#pragma once\r
\r
-#include <Raym/Raym.h>\r
+#include "Raym/Raym.h"\r
+#include "ry0/device/Tuner.h"\r
+\r
\r
namespace ry0\r
{\r
public Raym::TimerDelegate\r
{\r
private:\r
- Controller * _controller;\r
- Raym::Dictionary * _ctrls; // 制御情報\r
- Raym::Timer * _timer_periodic;\r
+ Controller * _controller;\r
+ int _tuner_count;\r
+ ry0::device::Tuner ** _tuners;\r
+\r
+ Raym::Dictionary * _ctrls;\r
+ Raym::Timer * _timer_periodic;\r
\r
protected:\r
Streaming();\r
\r
void mapping(int tuner, int channel, int port);\r
\r
- // タイマ満了IF (from Timer)\r
- void timerExpired(Raym::Timer *timer, void *userInfo);\r
+ void timerExpired(Raym::Timer *timer, void *user_info);\r
};\r
\r
-\r
} // iPTd\r
} // ry0\r