Пример #1
0
void eDVBServiceRecord::serviceEvent(int event)
{
	eDebug("RECORD service event %d", event);
	switch (event)
	{
	case eDVBServicePMTHandler::eventTuned:
	{
		eDebug("tuned..");
		m_tuned = 1;

			/* start feeding EIT updates */
		ePtr<iDVBDemux> m_demux;
		if (!m_service_handler.getDataDemux(m_demux))
		{
			eServiceReferenceDVB &ref = (eServiceReferenceDVB&) m_ref;
			int sid = ref.getParentServiceID().get();
			if (!sid)
				sid = ref.getServiceID().get();
			if ( ref.getParentTransportStreamID().get() &&
				ref.getParentTransportStreamID() != ref.getTransportStreamID() )
				m_event_handler.startOther(m_demux, sid);
			else
				m_event_handler.start(m_demux, sid);
		}

		if (m_state == stateRecording && m_want_record)
			doRecord();
		m_event((iRecordableService*)this, evTunedIn);
		break;
	}
	case eDVBServicePMTHandler::eventTuneFailed:
	{
		eDebug("record failed to tune");
		m_event((iRecordableService*)this, evTuneFailed);
		break;
	}
	case eDVBServicePMTHandler::eventNewProgramInfo:
	{
		if (m_state == stateIdle)
			doPrepare();
		else if (m_want_record) /* doRecord can be called from Prepared and Recording state */
			doRecord();
		m_event((iRecordableService*)this, evNewProgramInfo);
		break;
	}
	case eDVBServicePMTHandler::eventMisconfiguration:
		m_error = errMisconfiguration;
		m_event((iRecordableService*)this, evTuneFailed);
		break;
	case eDVBServicePMTHandler::eventNoResources:
		m_error = errNoResources;
		m_event((iRecordableService*)this, evTuneFailed);
		break;
	case eDVBServicePMTHandler::eventStopped:
		/* recording data source has stopped, stop recording */
		stop();
		m_event((iRecordableService*)this, evRecordAborted);
		break;
	}
}
Пример #2
0
void eDVBServiceStream::serviceEvent(int event)
{
	eDebug("STREAM service event %d", event);
	switch (event)
	{
	case eDVBServicePMTHandler::eventTuned:
	{
		eDebug("tuned..");
		m_tuned = 1;

			/* start feeding EIT updates */
		ePtr<iDVBDemux> m_demux;
		if (!m_service_handler.getDataDemux(m_demux))
		{
			eServiceReferenceDVB &ref = (eServiceReferenceDVB&) m_ref;
			int sid = ref.getParentServiceID().get();
			if (!sid)
				sid = ref.getServiceID().get();
			if ( ref.getParentTransportStreamID().get() &&
				ref.getParentTransportStreamID() != ref.getTransportStreamID() )
				m_event_handler.startOther(m_demux, sid);
			else
				m_event_handler.start(m_demux, sid);
		}

		if (m_state == stateRecording && m_want_record)
			doRecord();
		break;
	}
	case eDVBServicePMTHandler::eventTuneFailed:
	{
		eDebug("stream failed to tune");
		tuneFailed();
		break;
	}
	case eDVBServicePMTHandler::eventNewProgramInfo:
	{
		if (m_state == stateIdle)
			doPrepare();
		else if (m_want_record) /* doRecord can be called from Prepared and Recording state */
			doRecord();
		break;
	}
	case eDVBServicePMTHandler::eventMisconfiguration:
		tuneFailed();
		break;
	case eDVBServicePMTHandler::eventNoResources:
		tuneFailed();
		break;
	}
}
Пример #3
0
void eDVBServiceStream::serviceEvent(int event)
{
	eDebug("[eDVBServiceStream] STREAM service event %d", event);
	if(event == eDVBServicePMTHandler::eventTuneFailed || event == eDVBServicePMTHandler::eventMisconfiguration || event == eDVBServicePMTHandler::eventNoResources)
		eventUpdate(event);

	switch (event)
	{
	case eDVBServicePMTHandler::eventTuned:
	{
		eDebug("[eDVBServiceStream] tuned.. m_state %d m_want_record %d", m_state, m_want_record);
		m_tuned = 1;

			/* start feeding EIT updates */
		ePtr<iDVBDemux> m_demux;
		if (!m_service_handler.getDataDemux(m_demux))
		{
			eServiceReferenceDVB &ref = (eServiceReferenceDVB&) m_ref;
			m_event_handler.start(m_demux, ref);
		}

		if (m_state > stateIdle && m_want_record)
			doRecord();
		break;
	}
	case eDVBServicePMTHandler::eventTuneFailed:
	{
		eDebug("stream failed to tune");
		tuneFailed();
		break;
	}
	case eDVBServicePMTHandler::eventNewProgramInfo:
	{
		if (m_state == stateIdle)
			doPrepare();
		else if (m_want_record) /* doRecord can be called from Prepared and Recording state */
			doRecord();
		break;
	}
	case eDVBServicePMTHandler::eventMisconfiguration:
		tuneFailed();
		break;
	case eDVBServicePMTHandler::eventNoResources:
		tuneFailed();
		break;
	}
	if(event != eDVBServicePMTHandler::eventTuneFailed && event != eDVBServicePMTHandler::eventMisconfiguration && event != eDVBServicePMTHandler::eventNoResources)
		eventUpdate(event);
}
Пример #4
0
RESULT eDVBServiceRecord::start(bool simulate)
{
	m_simulate = simulate;
	m_want_record = 1;
		/* when tune wasn't yet successfully, doRecord stays in "prepared"-state which is fine. */
	m_event((iRecordableService*)this, evStart);
	return doRecord();
}
Пример #5
0
RESULT eServiceMP3Record::start(bool simulate)
{
	m_simulate = simulate;
	m_event((iRecordableService*)this, evStart);
	if (simulate)
		return 0;
	return doRecord();
}
Пример #6
0
int eDVBServiceStream::start(const char *serviceref, int fd)
{
	if (m_state != stateIdle) return -1;
	m_ref = eServiceReferenceDVB(serviceref);
	if (doPrepare() < 0) return -1;
	m_target_fd = fd;
	m_want_record = 1;
	return doRecord();
}
Пример #7
0
//
// Your standard server-side xpc main
//
int main (int argc, char * const argv[])
{
    const char *name = serviceName;
    if (const char *s = getenv("SYSPOLICYNAME"))
        name = s;

//    extern char *optarg;
    extern int optind;
    int arg;
    while ((arg = getopt(argc, argv, "v")) != -1)
        switch (arg) {
        case 'v':
            break;
        case '?':
            usage();
        }
    if (optind < argc)
        usage();

    dispatch_queue_t queue = dispatch_queue_create("server", 0);
    xpc_connection_t service = xpc_connection_create_mach_service(name, queue, XPC_CONNECTION_MACH_SERVICE_LISTENER /* | XPC_CONNECTION_MACH_SERVICE_PRIVILEGED */);

    xpc_connection_set_event_handler(service, ^(xpc_object_t cmsg) {
        if (xpc_get_type(cmsg) == XPC_TYPE_CONNECTION) {
            xpc_connection_t connection = xpc_connection_t(cmsg);
            syslog(LOG_DEBUG, "Connection from pid %d", xpc_connection_get_pid(connection));
            xpc_connection_set_event_handler(connection, ^(xpc_object_t msg) {
                if (xpc_get_type(msg) == XPC_TYPE_DICTIONARY) {
                    const char *function = xpc_dictionary_get_string(msg, "function");
                    syslog(LOG_DEBUG, "pid %d requested %s", xpc_connection_get_pid(connection), function);
                    xpc_object_t reply = xpc_dictionary_create_reply(msg);
                    try {
                        if (function == NULL) {
                            xpc_dictionary_set_int64(reply, "error", errSecCSInternalError);
                        } else if (!strcmp(function, "assess")) {
                            doAssess(msg, reply);
                        } else if (!strcmp(function, "update")) {
                            doUpdate(msg, reply);
                        } else if (!strcmp(function, "record")) {
                            doRecord(msg, reply, connection);
                        } else {
                            xpc_dictionary_set_int64(reply, "error", errSecCSInternalError);
                        }
                    } catch (...) {
                        xpc_dictionary_set_int64(reply, "error", errSecCSInternalError);
                    }
                    xpc_connection_send_message(connection, reply);
                    xpc_release(reply);
                }
            });
            xpc_connection_resume(connection);
        } else {
Пример #8
0
//0:exit,1:continue
int CwxBinlogOp::doCommand(char* szCmd) {
  string strCmd;
  list < string > value;
  CwxCommon::trim(szCmd);
  strCmd = szCmd;
  CwxCommon::split(strCmd, value, ' ');
  list<string>::iterator iter = value.begin();
  //remove the empty value
  while (iter != value.end()) {
    if ((*iter).length() == 0) {
      value.erase(iter);
      iter = value.begin();
      continue;
    }
    iter++;
  }
  if (value.size() == 0)
    return 1;

  iter = value.begin();
  CWX_UINT32 uiItemNum = value.size();
  if (0 == strcasecmp((*iter).c_str(), "help")) {
    doHelp();
  } else if (0 == strcasecmp((*iter).c_str(), "info")) {
    doInfo();
  } else if (0 == strcasecmp((*iter).c_str(), "next")) {
    CWX_UINT32 uiNum = 1;
    if (1 != uiItemNum) {
      iter++;
      uiNum = strtoul((*iter).c_str(), NULL, 0);
    }
    doNext(uiNum);
  } else if (0 == strcasecmp((*iter).c_str(), "prev")) {
    CWX_UINT32 uiNum = 1;
    if (1 != uiItemNum) {
      iter++;
      uiNum = strtoul((*iter).c_str(), NULL, 0);
    }
    doPrev(uiNum);
  } else if (0 == strcasecmp((*iter).c_str(), "sid")) {
    if (2 != uiItemNum) {
      printf("Invalid sid command, using: sid value.\n");
      return 1;
    }
    iter++;
    doSid(strtoull((*iter).c_str(), NULL, 0));
  } else if (0 == strcasecmp((*iter).c_str(), "rec")) {
    if (2 != uiItemNum) {
      printf("Invalid rec command, using: rec value.\n");
      return 1;
    }
    iter++;
    doRecord(strtoul((*iter).c_str(), NULL, 0));
  } else if (0 == strcasecmp((*iter).c_str(), "group")) {
    if (2 != uiItemNum) {
      printf("Invalid group command, using: group value.\n");
      return 1;
    }
    iter++;
    doGroup(strtoul((*iter).c_str(), NULL, 0));
  } else if (0 == strcasecmp((*iter).c_str(), "key")) {
    if (3 != uiItemNum) {
      printf("Invalid key command, using: key k v.\n");
      return 1;
    }
    iter++;
    string strKey = *iter;
    doKey(strKey.c_str(), (*iter).c_str());
  } else if (0 == strcasecmp((*iter).c_str(), "head")) {
    doHead();
  } else if (0 == strcasecmp((*iter).c_str(), "data")) {
    doData();
  } else if (0 == strcasecmp((*iter).c_str(), "save")) {
    if (1 == uiItemNum) {
      printf("Invalid save command, using: save file.\n");
      return 1;
    }
    iter++;
    doSave(*iter);
  } else if (0 == strcasecmp((*iter).c_str(), "exit")) {
    return 0;
  } else {
    printf("Invalid command %s\n", (*iter).c_str());
    doHelp();
  }
  return 1;
}