⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dvdcontrol.c

📁 基于linux的DVD播放器程序
💻 C
📖 第 1 页 / 共 5 页
字号:
 * @retval DVD_E_FailedToSend Failed to send the request. * @retval DVD_E_Unspecified Failure.  */DVDResult_t DVDGetState(DVDNav_t *nav, char **state){  MsgEvent_t ev;  int32_t serial;  ev.type = MsgEventQDVDCtrl;  DVD_SETSERIAL(nav, ev.dvdctrl.cmd);  serial = ev.dvdctrl.cmd.any.serial;  ev.dvdctrl.cmd.type = DVDCtrlGetState;  if(MsgSendEvent(nav->msgq, nav->client, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    while(1) {    if(MsgNextEvent(nav->msgq, &ev) == -1) {      return DVD_E_Unspecified;    }    if((ev.type == MsgEventQDVDCtrl) &&       (ev.dvdctrl.cmd.type == DVDCtrlRetVal) &&       (ev.dvdctrl.cmd.retval.serial == serial)) {      return ev.dvdctrl.cmd.retval.val;    }    if((ev.type == MsgEventQDVDCtrlLong) &&       (ev.dvdctrllong.cmd.type == DVDCtrlLongState)) {      if(ev.dvdctrllong.cmd.state.xmlstr[0] != '\0') {	*state = strdup(ev.dvdctrllong.cmd.state.xmlstr);	if(*state != NULL) {	  return DVD_E_Ok;	}      }      return DVD_E_Unspecified;    }  } }/** * Get the DVDDiscID * This is a unique id used to identify a specific DVD. * Works on discs as well as discimages and files. * * @param nav Specifies the connection to the DVD navigator. * @param dvdid should point to a 16 bytes array where the discid will be * returned. *  * @return If successful DVD_E_Ok is returned and the char pointer pointed * to by state will be updated. Otherwise an error code  is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_FailedToSend Failed to send the request. * @retval DVD_E_Unspecified Failure.  */DVDResult_t DVDGetDiscID(DVDNav_t *nav, unsigned char *dvdid){  MsgEvent_t ev;  int32_t serial;  ev.type = MsgEventQDVDCtrl;  DVD_SETSERIAL(nav, ev.dvdctrl.cmd);  serial = ev.dvdctrl.cmd.any.serial;  ev.dvdctrl.cmd.type = DVDCtrlGetDiscID;  if(MsgSendEvent(nav->msgq, nav->client, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    while(1) {    if(MsgNextEvent(nav->msgq, &ev) == -1) {      return DVD_E_Unspecified;    }    if((ev.type == MsgEventQDVDCtrl) &&       (ev.dvdctrl.cmd.type == DVDCtrlRetVal) &&       (ev.dvdctrl.cmd.retval.serial == serial)) {      return ev.dvdctrl.cmd.retval.val;    }    if((ev.type == MsgEventQDVDCtrl) &&       (ev.dvdctrl.cmd.type == DVDCtrlDiscID)) {      int n;      memcpy(dvdid, ev.dvdctrl.cmd.discid.id,	     sizeof(ev.dvdctrl.cmd.discid.id));      for(n = 0; n < sizeof(ev.dvdctrl.cmd.discid.id); n++) {	if(dvdid[n] != 0) {	  break;	}      }      if(n != sizeof(ev.dvdctrl.cmd.discid.id)) {	return DVD_E_Ok;      } else {	return DVD_E_Unspecified;      }    }  } }/** * Get the UDF or ISO VolumeIdentifier and VolumeSetIdentifier if available. * * @param nav Specifies the connection to the DVD navigator. * @param type 0 - gets the UDF ids if available else the ISO ids else fails. * 1 - gets the UDF ids if available else fails. * 2 - gets the ISO ids if available else fails. * @param return_type Is set to 0 if no ids could be returned, * 1 if the UDF ids were returned and 2 if the ISO ids were retured. * @param volid Pointer to a 33 bytes array, where the volume identifier * is returned as a null terminated string. * If NULL the volid is not returned. * @param volsetid Pointer to a 128 bytes array, or NULL if not wanted, * where the volume set identifier is returned (not null terminated). *  * @return If successful DVD_E_Ok is returned and the char pointer pointed * to by state will be updated. Otherwise an error code  is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_FailedToSend Failed to send the request. * @retval DVD_E_Unspecified Failure.  */DVDResult_t DVDGetVolumeIdentifiers(DVDNav_t *nav,				    int type, int *return_type,				    char *volid,				    unsigned char *volsetid){  MsgEvent_t ev;  int32_t serial;  ev.type = MsgEventQDVDCtrl;  DVD_SETSERIAL(nav, ev.dvdctrl.cmd);  serial = ev.dvdctrl.cmd.any.serial;  ev.dvdctrl.cmd.type = DVDCtrlGetVolIds;  ev.dvdctrl.cmd.volids.voltype = type;  if(MsgSendEvent(nav->msgq, nav->client, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    while(1) {    if(MsgNextEvent(nav->msgq, &ev) == -1) {      return DVD_E_Unspecified;    }    if((ev.type == MsgEventQDVDCtrl) &&       (ev.dvdctrl.cmd.type == DVDCtrlRetVal) &&       (ev.dvdctrl.cmd.retval.serial == serial)) {      return ev.dvdctrl.cmd.retval.val;    }    if((ev.type == MsgEventQDVDCtrlLong) &&       (ev.dvdctrllong.cmd.type == DVDCtrlLongVolIds)) {      if((*return_type = ev.dvdctrllong.cmd.volids.voltype) != 0) {	if(volid != NULL) {	  memcpy(volid, ev.dvdctrllong.cmd.volids.volid,		 sizeof(ev.dvdctrllong.cmd.volids.volid));	}	if(volsetid != NULL) {	  memcpy(volsetid, ev.dvdctrllong.cmd.volids.volsetid,		 sizeof(ev.dvdctrllong.cmd.volids.volsetid));	}      }      return DVD_E_Ok;    }  } }/** @} end of dvdinfo *//**  * @todo Remove this function. * * @param nav Specifies the connection to the DVD navigator. * @param ev is the returned message in case DVD_E_Ok is returned. * * @return If successful DVD_E_Ok is returned. Otherwise an error code * is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_Unspecified. Failure. */DVDResult_t DVDNextEvent(DVDNav_t *nav, MsgEvent_t *ev){    if(MsgNextEvent(nav->msgq, ev) == -1) {    return DVD_E_Unspecified;  }    return DVD_E_Ok;  } #if (defined(BSD) && (BSD >= 199306))DVDResult_t DVDNextEventNonBlocking(DVDNav_t *nav, MsgEvent_t *ev){    if(MsgNextEventNonBlocking(nav->msgq, ev) == -1) {    return DVD_E_Unspecified;  }    return DVD_E_Ok;} #endifDVDResult_t DVDRequestInput(DVDNav_t *nav, InputMask_t mask){  MsgEvent_t ev;  ev.type = MsgEventQReqInput;  ev.reqinput.mask = mask;    if((nav->voclient == CLIENT_NONE) ||     (nav->voclient == -1)) {    nav->voclient = get_vo_client(nav->msgq);  }    switch(nav->voclient) {  case -1:  case CLIENT_NONE:    fprintf(stderr, "dvdctrl: voclient error\n");    return DVD_E_Unspecified;    break;  default:    break;  }    if(MsgSendEvent(nav->msgq, nav->voclient, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    return DVD_E_Ok;}/** @defgroup dvdctrl DVD control functions * These functions are used for controlling the * DVD navigator. * * These functions send commands and state information * to the DVD navigator. The DVD navigator performs the requested * actions if possible and updates the state. * The @link dvdinfo DVD information functions @endlink provides * the functions for getting information from the DVD navigator. * @{ */DVDResult_t DVDSetAspectModeSrc(DVDNav_t *nav, AspectModeSrc_t mode_src){  MsgEvent_t ev;  ev.type = MsgEventQSetAspectModeSrc;  ev.setaspectmodesrc.mode_src = mode_src;  if((nav->voclient == CLIENT_NONE) ||     (nav->voclient == -1)) {    nav->voclient = get_vo_client(nav->msgq);  }  switch(nav->voclient) {  case -1:  case CLIENT_NONE:    fprintf(stderr, "dvdctrl: voclient error\n");    return DVD_E_Unspecified;    break;  default:    break;  }    if(MsgSendEvent(nav->msgq, nav->voclient, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    return DVD_E_Ok;}DVDResult_t DVDSetSrcAspect(DVDNav_t *nav, AspectModeSrc_t mode_sender,			    uint16_t aspect_frac_n, uint16_t aspect_frac_d){  MsgEvent_t ev;  ev.type = MsgEventQSetSrcAspect;  ev.setsrcaspect.mode_src = mode_sender;  ev.setsrcaspect.aspect_frac_n = aspect_frac_n;  ev.setsrcaspect.aspect_frac_d = aspect_frac_d;    if((nav->voclient == CLIENT_NONE) ||     (nav->voclient == -1)) {    nav->voclient = get_vo_client(nav->msgq);  }  switch(nav->voclient) {  case -1:  case CLIENT_NONE:    fprintf(stderr, "dvdctrl: voclient error\n");    return DVD_E_Unspecified;    break;  default:    break;  }    if(MsgSendEvent(nav->msgq, nav->voclient, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    return DVD_E_Ok;}DVDResult_t DVDSetZoomMode(DVDNav_t *nav, ZoomMode_t zoom_mode){  MsgEvent_t ev;  ev.type = MsgEventQSetZoomMode;  ev.setzoommode.mode = zoom_mode;    if((nav->voclient == CLIENT_NONE) ||     (nav->voclient == -1)) {    nav->voclient = get_vo_client(nav->msgq);  }  switch(nav->voclient) {  case -1:  case CLIENT_NONE:    fprintf(stderr, "dvdctrl: voclient error\n");    return DVD_E_Unspecified;    break;  default:    break;  }    if(MsgSendEvent(nav->msgq, nav->voclient, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    return DVD_E_Ok;}/**  * Save a screenshot to a file. * @param nav Specifies the connection to the DVD navigator. * @param mode Specifies the type of screenshot. *   Can be ScreenshotModeWithoutSPU (just the video) or *   ScreenshotModeWithSPU (includes subtitles, menu overlays). * @param formatstr Specifies the filename format. *   If %i is included in the formatstr, it will be replaced by * a number that increments by one for each screenshot, starts at 0. *  %3i - leftpadded with spaces to width 3. *  %03i - leftpadded with zeros to width 3. *  %% - % * If formatstr is set to NULL, the previous format will be used, * so setting the string to "pic%02i.jpg" the first time and * then call with formatstr NULL will produce the files * "pic00.jpg", "pic01.jpg", "pic02.jpg", ... * If no formatstr has been set or an illegal one is set * the format will default to "shot%04i.jpg" * * @return If successful DVD_E_Ok is returned. Otherwise an error code * is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_FailedToSend Failed to send the request. */DVDResult_t DVDSaveScreenshot(DVDNav_t *nav, ScreenshotMode_t mode,			      char *formatstr){  MsgEvent_t ev;  ev.type = MsgEventQSaveScreenshot;  ev.savescreenshot.mode = mode;  if(formatstr) {    strncpy(ev.savescreenshot.formatstr, formatstr,	    sizeof(ev.savescreenshot.formatstr));        ev.savescreenshot.formatstr[sizeof(ev.savescreenshot.formatstr)-1] = '\0';  } else {    ev.savescreenshot.formatstr[0] = '\0';  }    if((nav->voclient == CLIENT_NONE) ||     (nav->voclient == -1)) {    nav->voclient = get_vo_client(nav->msgq);  }  switch(nav->voclient) {  case -1:  case CLIENT_NONE:    fprintf(stderr, "dvdctrl: voclient error\n");    return DVD_E_Unspecified;    break;  default:    break;  }    if(MsgSendEvent(nav->msgq, nav->voclient, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    return DVD_E_Ok;}/**  * Selects the directory where the dvd files are *.VOB *.IFO. * @todo implement * @param nav Specifies the connection to the DVD navigator. * @param  * @return If successful DVD_E_Ok is returned. Otherwise an error code * is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_FailedToSend Failed to send the request. */DVDResult_t DVDSetDVDRoot(DVDNav_t *nav, char *Path){  MsgEvent_t ev;  int32_t serial;  ev.type = MsgEventQDVDCtrlLong;  DVD_SETSERIAL(nav, ev.dvdctrllong.cmd);  serial = ev.dvdctrllong.cmd.any.serial;  ev.dvdctrllong.cmd.type = DVDCtrlLongSetDVDRoot;  strncpy(ev.dvdctrllong.cmd.dvdroot.path, Path,	  sizeof(ev.dvdctrllong.cmd.dvdroot.path));  ev.dvdctrllong.cmd.dvdroot.path[sizeof(ev.dvdctrllong.cmd.dvdroot.path)-1]    = '\0';    if(MsgSendEvent(nav->msgq, nav->client, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    while(1) {    if(MsgNextEvent(nav->msgq, &ev) == -1) {      return DVD_E_Unspecified;    }    if((ev.type == MsgEventQDVDCtrl) &&       (ev.dvdctrl.cmd.type == DVDCtrlRetVal) &&       (ev.dvdctrl.cmd.retval.serial == serial)) {      return ev.dvdctrl.cmd.retval.val;    }  }}/**  * Selects the button to the left of the current one. * @todo add mode return values * @param nav Specifies the connection to the DVD navigator. * * @return If successful DVD_E_Ok is returned. Otherwise an error code * is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_FailedToSend Failed to send the request. */DVDResult_t DVDLeftButtonSelect(DVDNav_t *nav){  MsgEvent_t ev;  ev.type = MsgEventQDVDCtrl;  DVD_SETSERIAL(nav, ev.dvdctrl.cmd);  ev.dvdctrl.cmd.type = DVDCtrlLeftButtonSelect;  if(MsgSendEvent(nav->msgq, nav->client, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    return DVD_E_Ok;}/** * Selects the button to the right of the current one. * @todo add mode return values * * @param nav Specifies the connection to the DVD navigator. * * @return If successful DVD_E_Ok is returned. Otherwise an error code * is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_FailedToSend Failed to send the request. */DVDResult_t DVDRightButtonSelect(DVDNav_t *nav){  MsgEvent_t ev;  ev.type = MsgEventQDVDCtrl;  DVD_SETSERIAL(nav, ev.dvdctrl.cmd);  ev.dvdctrl.cmd.type = DVDCtrlRightButtonSelect;  if(MsgSendEvent(nav->msgq, nav->client, &ev, 0) == -1) {    return DVD_E_FailedToSend;  }    return DVD_E_Ok;}/**  * Selects the button above the current one. * @todo add mode return values * * @param nav Specifies the connection to the DVD navigator. * * @return If successful DVD_E_Ok is returned. Otherwise an error code * is returned. * * @retval DVD_E_Ok Success. * @retval DVD_E_FailedToSend Failed to send the request. */DVDResult_t DVDUpperButtonSelect(DVDNav_t *nav){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -