00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "config.h"
00025
00026 #include "dvdnav_internal.h"
00027
00028
00029
00030 dvdnav_status_t dvdnav_still_skip(dvdnav_t *this) {
00031 if(!this) {
00032 printerr("Passed a NULL pointer.");
00033 return DVDNAV_STATUS_ERR;
00034 }
00035
00036 this->position_current.still = 0;
00037 this->skip_still = 1;
00038 this->sync_wait = 0;
00039 this->sync_wait_skip = 1;
00040
00041 return DVDNAV_STATUS_OK;
00042 }
00043
00044 dvdnav_status_t dvdnav_wait_skip(dvdnav_t *this) {
00045 if(!this) {
00046 printerr("Passed a NULL pointer.");
00047 return DVDNAV_STATUS_ERR;
00048 }
00049
00050 this->sync_wait = 0;
00051 this->sync_wait_skip = 1;
00052
00053 return DVDNAV_STATUS_OK;
00054 }
00055
00056 dvdnav_status_t dvdnav_get_number_of_titles(dvdnav_t *this, int32_t *titles) {
00057 if(!this || !titles) {
00058 printerr("Passed a NULL pointer.");
00059 return DVDNAV_STATUS_ERR;
00060 }
00061 if (!this->vm->vmgi) {
00062 printerr("Bad VM state.");
00063 return DVDNAV_STATUS_ERR;
00064 }
00065
00066 (*titles) = vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts;
00067
00068 return DVDNAV_STATUS_OK;
00069 }
00070
00071 dvdnav_status_t dvdnav_get_number_of_parts(dvdnav_t *this, int32_t title, int32_t *parts) {
00072 if(!this || !parts) {
00073 printerr("Passed a NULL pointer.");
00074 return DVDNAV_STATUS_ERR;
00075 }
00076 if (!this->vm->vmgi) {
00077 printerr("Bad VM state.");
00078 return DVDNAV_STATUS_ERR;
00079 }
00080 if ((title < 1) || (title > vm_get_vmgi(this->vm)->tt_srpt->nr_of_srpts) ) {
00081 printerr("Passed a title number out of range.");
00082 return DVDNAV_STATUS_ERR;
00083 }
00084
00085 (*parts) = vm_get_vmgi(this->vm)->tt_srpt->title[title-1].nr_of_ptts;
00086
00087 return DVDNAV_STATUS_OK;
00088 }
00089
00090 dvdnav_status_t dvdnav_current_title_info(dvdnav_t *this, int32_t *title, int32_t *part) {
00091 int32_t retval;
00092
00093 if(!this || !title || !part) {
00094 printerr("Passed a NULL pointer.");
00095 return DVDNAV_STATUS_ERR;
00096 }
00097
00098 pthread_mutex_lock(&this->vm_lock);
00099 if (!this->vm->vtsi || !this->vm->vmgi) {
00100 printerr("Bad VM state.");
00101 pthread_mutex_unlock(&this->vm_lock);
00102 return DVDNAV_STATUS_ERR;
00103 }
00104 if (!this->started) {
00105 printerr("Virtual DVD machine not started.");
00106 pthread_mutex_unlock(&this->vm_lock);
00107 return DVDNAV_STATUS_ERR;
00108 }
00109 if (!this->vm->state.pgc) {
00110 printerr("No current PGC.");
00111 pthread_mutex_unlock(&this->vm_lock);
00112 return DVDNAV_STATUS_ERR;
00113 }
00114 if ( (this->vm->state.domain == VTSM_DOMAIN)
00115 || (this->vm->state.domain == VMGM_DOMAIN) ) {
00116
00117 vm_get_current_menu(this->vm, part);
00118 if (*part > -1) {
00119 *title = 0;
00120 pthread_mutex_unlock(&this->vm_lock);
00121 return DVDNAV_STATUS_OK;
00122 }
00123 }
00124 if (this->vm->state.domain == VTS_DOMAIN) {
00125 retval = vm_get_current_title_part(this->vm, title, part);
00126 pthread_mutex_unlock(&this->vm_lock);
00127 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
00128 }
00129 printerr("Not in a title or menu.");
00130 pthread_mutex_unlock(&this->vm_lock);
00131 return DVDNAV_STATUS_ERR;
00132 }
00133
00134 dvdnav_status_t dvdnav_title_play(dvdnav_t *this, int32_t title) {
00135 if(!this) {
00136 printerr("Passed a NULL pointer.");
00137 return DVDNAV_STATUS_ERR;
00138 }
00139 return dvdnav_part_play(this, title, 1);
00140 }
00141
00142 dvdnav_status_t dvdnav_part_play(dvdnav_t *this, int32_t title, int32_t part) {
00143 int32_t retval;
00144
00145 if(!this) {
00146 printerr("Passed a NULL pointer.");
00147 return DVDNAV_STATUS_ERR;
00148 }
00149
00150 pthread_mutex_lock(&this->vm_lock);
00151 if (!this->vm->vmgi) {
00152 printerr("Bad VM state.");
00153 pthread_mutex_unlock(&this->vm_lock);
00154 return DVDNAV_STATUS_ERR;
00155 }
00156 if (!this->started) {
00157
00158 vm_start(this->vm);
00159 this->started = 1;
00160 }
00161 if (!this->vm->state.pgc) {
00162 printerr("No current PGC.");
00163 pthread_mutex_unlock(&this->vm_lock);
00164 return DVDNAV_STATUS_ERR;
00165 }
00166 if((title < 1) || (title > this->vm->vmgi->tt_srpt->nr_of_srpts)) {
00167 printerr("Title out of range.");
00168 pthread_mutex_unlock(&this->vm_lock);
00169 return DVDNAV_STATUS_ERR;
00170 }
00171 if((part < 1) || (part > this->vm->vmgi->tt_srpt->title[title-1].nr_of_ptts)) {
00172 printerr("Part out of range.");
00173 pthread_mutex_unlock(&this->vm_lock);
00174 return DVDNAV_STATUS_ERR;
00175 }
00176
00177 retval = vm_jump_title_part(this->vm, title, part);
00178 if (retval)
00179 this->vm->hop_channel++;
00180 pthread_mutex_unlock(&this->vm_lock);
00181
00182 return retval ? DVDNAV_STATUS_OK : DVDNAV_STATUS_ERR;
00183 }
00184
00185 dvdnav_status_t dvdnav_part_play_auto_stop(dvdnav_t *this, int32_t title,
00186 int32_t part, int32_t parts_to_play) {
00187
00188 if (dvdnav_part_play(this, title, part) == DVDNAV_STATUS_OK)
00189 printerr("Not implemented yet.");
00190 return DVDNAV_STATUS_ERR;
00191 }
00192
00193 dvdnav_status_t dvdnav_time_play(dvdnav_t *this, int32_t title,
00194 uint64_t time) {
00195 if(!this) {
00196 printerr("Passed a NULL pointer.");
00197 return DVDNAV_STATUS_ERR;
00198 }
00199
00200
00201 printerr("Not implemented yet.");
00202 return DVDNAV_STATUS_ERR;
00203 }
00204
00205 dvdnav_status_t dvdnav_stop(dvdnav_t *this) {
00206 if(!this) {
00207 printerr("Passed a NULL pointer.");
00208 return DVDNAV_STATUS_ERR;
00209 }
00210
00211 pthread_mutex_lock(&this->vm_lock);
00212 this->vm->stopped = 1;
00213 pthread_mutex_unlock(&this->vm_lock);
00214 return DVDNAV_STATUS_OK;
00215 }
00216
00217 dvdnav_status_t dvdnav_go_up(dvdnav_t *this) {
00218 if(!this) {
00219 printerr("Passed a NULL pointer.");
00220 return DVDNAV_STATUS_ERR;
00221 }
00222
00223
00224 pthread_mutex_lock(&this->vm_lock);
00225 vm_jump_up(this->vm);
00226 pthread_mutex_unlock(&this->vm_lock);
00227
00228 return DVDNAV_STATUS_OK;
00229 }