int main(int argc, const char *argv[]) { BLURAY *bd; const BLURAY_DISC_INFO *info; if (argc != 2) { fprintf(stderr, "usage: %s <disc_root>\n", argv[0]); return 1; } bd = bd_open(argv[1], NULL); if (!bd) { fprintf(stderr, "error opening BD disc %s\n", argv[1]); return -1; } info = bd_get_disc_info(bd); if (!info->bluray_detected) { fprintf(stderr, "no BD disc detected in %s\n", argv[1]); bd_close(bd); return -1; } _indx_print(info); bd_close(bd); return 0; }
int bd_check_file(FILE *fp, FileInfo *finfo) { int nRet = 0; int count; parse_priv * par_priv = NULL; mp_msg("bd_check_file\n"); BLURAY *bd = bd_open(finfo->filepath, NULL); if (bd) { count = bd_get_titles(bd, TITLES_FILTER_DUP_CLIP); mp_msg("Get titles: %d\n", count); if (count > 0) nRet = 1; else bd_close(bd); } if (nRet == 1) { par_priv = (parse_priv *)malloc(sizeof(parse_priv)); par_priv->bd = bd; par_priv->title_num = count; finfo->priv = (void *)par_priv; } return nRet; }
void CBlurayDirectory::Dispose() { if(m_bd) { bd_close(m_bd); m_bd = nullptr; } }
static void bluray_stream_close(stream_t *s) { struct bluray_priv_s *b = s->priv; bd_close(b->bd); b->bd = NULL; free(b); }
void BDRingBuffer::close(void) { if (bdnav) { if (m_currentTitleInfo) bd_free_title_info(m_currentTitleInfo); bd_close(bdnav); bdnav = NULL; } }
static bool BlurayMenuSupported(const cString& Path) { bool result = false; #ifdef HAVE_LIBBLURAY BLURAY *bdh = bd_open(Path, NULL); if (bdh) { const BLURAY_DISC_INFO *di = bd_get_disc_info(bdh); if (di->bluray_detected && !di->num_unsupported_titles) result = true; bd_close(bdh); } #endif return result; }
/*********************************************************************** * hb_bd_close *********************************************************************** * Closes and frees everything **********************************************************************/ void hb_bd_close( hb_bd_t ** _d ) { hb_bd_t * d = *_d; int ii; if ( d->title_info ) { for ( ii = 0; ii < d->title_count; ii++ ) bd_free_title_info( d->title_info[ii] ); free( d->title_info ); } if( d->stream ) hb_stream_close( &d->stream ); if( d->bd ) bd_close( d->bd ); if( d->path ) free( d->path ); free( d ); *_d = NULL; }
CBDDemuxer::~CBDDemuxer(void) { if (m_pTitle) { bd_free_title_info(m_pTitle); m_pTitle = nullptr; } if (m_pBD) { bd_close(m_pBD); m_pBD = nullptr; } if (m_pb) { av_free(m_pb->buffer); av_free(m_pb); } SafeRelease(&m_lavfDemuxer); SAFE_CO_FREE(m_rtOffset); }
/*********************************************************************** * hb_bd_init *********************************************************************** * **********************************************************************/ hb_bd_t * hb_bd_init( hb_handle_t *h, char * path ) { hb_bd_t * d; int ii; d = calloc( sizeof( hb_bd_t ), 1 ); d->h = h; /* Open device */ d->bd = bd_open( path, NULL ); if( d->bd == NULL ) { /* * Not an error, may be a stream - which we'll try in a moment. */ hb_log( "bd: not a bd - trying as a stream/file instead" ); goto fail; } d->title_count = bd_get_titles( d->bd, TITLES_RELEVANT, 0 ); if ( d->title_count == 0 ) { hb_log( "bd: not a bd - trying as a stream/file instead" ); goto fail; } d->title_info = calloc( sizeof( BLURAY_TITLE_INFO* ) , d->title_count ); for ( ii = 0; ii < d->title_count; ii++ ) { d->title_info[ii] = bd_get_title_info( d->bd, ii, 0 ); } qsort(d->title_info, d->title_count, sizeof( BLURAY_TITLE_INFO* ), title_info_compare_mpls ); d->path = strdup( path ); return d; fail: if( d->bd ) bd_close( d->bd ); free( d ); return NULL; }
void BDRingBuffer::close(void) { if (bdnav) { m_infoLock.lock(); QHash<uint32_t, BLURAY_TITLE_INFO*>::iterator it; for (it = m_cachedTitleInfo.begin(); it !=m_cachedTitleInfo.end(); ++it) bd_free_title_info(it.value()); m_cachedTitleInfo.clear(); for (it = m_cachedPlaylistInfo.begin(); it !=m_cachedPlaylistInfo.end(); ++it) bd_free_title_info(it.value()); m_cachedPlaylistInfo.clear(); m_infoLock.unlock(); bd_close(bdnav); bdnav = NULL; } ClearOverlays(); }
int main(int argc, char *argv[]) { int title = -1; int verbose = 0; int args = 0; /* * parse arguments */ if (argc < 2) { printf("\nUsage:\n %s [-v] [-t <title>] <media_path> [<keyfile_path>]\n\n", argv[0]); return -1; } if (!strcmp(argv[1+args], "-v")) { verbose = 1; args++; } if (!strcmp(argv[1+args], "-t")) { args++; title = atoi(argv[1+args]); args++; printf("Requested title %d\n", title); } if (verbose) { printf("Enabling verbose debug\n"); bd_set_debug_mask(bd_get_debug_mask() | DBG_HDMV | DBG_BLURAY); } printf("\n"); /* * open and setup */ BLURAY *bd = bd_open(argv[1+args], argv[2+args]); if (!bd) { printf("bd_open(\'%s\') failed\n", argv[1]); return -1; } bd_set_player_setting (bd, BLURAY_PLAYER_SETTING_PARENTAL, 99); bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_AUDIO_LANG, "eng"); bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_PG_LANG, "eng"); bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_MENU_LANG, "eng"); bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_COUNTRY_CODE, NULL); /* * play */ printf("Running first play movie object\n"); fflush(stdout); bd_play(bd); _print_events(bd); printf("\n"); /* * play title */ if (title >= 0) { printf("Playing title %d\n", title); fflush(stdout); bd_play_title(bd, title); _print_events(bd); printf("\n"); } /* * play playlist */ _play_pl(bd); _play_pl(bd); _play_pl(bd); /* * clean up */ bd_close(bd); return 0; }
int main(int argc, char* argv[]) { int nx, nt, nkx, nkz, ix, it, ikx, ikz, nz, iz, nbt, nbb, nbl, nbr, nxb, nzb, isx, isz; float dt, dx, dkx, kx, dz, dkz, kz, tmpdt, pi=SF_PI, o1, o2, kx0, kz0; float **nxt, **old, **cur, **ukr, **dercur, **derold, *wav; float **vx, vx2, vx0, vx02, **vz, vz2, vz0, vz02, **yi, yi0, **se, se0; float ***aa, dx2, dz2, dx4, dz4, ct, cb, cl, cr; //top, bottom, left, right float w1, w10, w2, w20, w3, w30, h1, h10, h2, h20, h3, h30; float cosg, cosg0, cosg2, cosg02, sing, sing0, sing2, sing02; float vk, vk2, tmpvk, k2, err, dt2, kx1, kz1; kiss_fft_cpx **uk, *ctracex, *ctracez; kiss_fft_cfg cfgx, cfgxi, cfgz, cfgzi; sf_file out, velx, velz, source, yita, seta; bool opt; /* optimal padding */ // #ifdef _OPENMP // int nth; // #endif sf_init(argc,argv); out = sf_output("out"); velx = sf_input("velx"); /* velocity */ velz = sf_input("velz"); /* velocity */ yita = sf_input("yita"); /* anistropic parameter*/ source = sf_input("in"); /* source wavlet*/ seta = sf_input("seta"); /* TTI angle*/ // if (SF_FLOAT != sf_gettype(inp)) sf_error("Need float input"); if (SF_FLOAT != sf_gettype(velx)) sf_error("Need float input"); if (SF_FLOAT != sf_gettype(velz)) sf_error("Need float input"); if (SF_FLOAT != sf_gettype(source)) sf_error("Need float input"); if (SF_FLOAT != sf_gettype(seta)) sf_error("Need float input"); if (!sf_histint(velx,"n1",&nx)) sf_error("No n1= in input"); if (!sf_histfloat(velx,"d1",&dx)) sf_error("No d1= in input"); if (!sf_histint(velx,"n2",&nz)) sf_error("No n2= in input"); if (!sf_histfloat(velx,"d2",&dz)) sf_error("No d2= in input"); if (!sf_histfloat(velx,"o1",&o1)) o1=0.0; if (!sf_histfloat(velx,"o2",&o2)) o2=0.0; // if (!sf_histint(inp,"n2",&nt)) sf_error("No n2= in input"); // if (!sf_histfloat(inp,"d2",&dt)) sf_error("No d2= in input"); if (!sf_getbool("opt",&opt)) opt=true; /* if y, determine optimal size for efficiency */ if (!sf_getfloat("dt",&dt)) sf_error("Need dt input"); if (!sf_getint("nt",&nt)) sf_error("Need nt input"); if (!sf_getint("isx",&isx)) sf_error("Need isx input"); if (!sf_getint("isz",&isz)) sf_error("Need isz input"); if (!sf_getfloat("err",&err)) err = 0.0001; if (!sf_getint("nbt",&nbt)) nbt=44; if (!sf_getint("nbb",&nbb)) nbb=44; if (!sf_getint("nbl",&nbl)) nbl=44; if (!sf_getint("nbr",&nbr)) nbr=44; if (!sf_getfloat("ct",&ct)) ct = 0.01; /*decaying parameter*/ if (!sf_getfloat("cb",&cb)) cb = 0.01; /*decaying parameter*/ if (!sf_getfloat("cl",&cl)) cl = 0.01; /*decaying parameter*/ if (!sf_getfloat("cr",&cr)) cr = 0.01; /*decaying parameter*/ sf_putint(out,"n1",nx); sf_putfloat(out,"d1",dx); // sf_putfloat(out,"o1",x0); sf_putint(out,"n2",nz); sf_putfloat(out,"d2",dz); sf_putint(out,"n3",nt); sf_putfloat(out,"d3",dt); sf_putfloat(out,"o1",o1); sf_putfloat(out,"o2",o2); sf_putfloat(out,"o3",0.0); nxb = nx + nbl + nbr; nzb = nz + nbt + nbb; nkx = opt? kiss_fft_next_fast_size(nxb): nxb; nkz = opt? kiss_fft_next_fast_size(nzb): nzb; if (nkx != nxb) sf_warning("nkx padded to %d",nkx); if (nkz != nzb) sf_warning("nkz padded to %d",nkz); dkx = 1./(nkx*dx); kx0 = -0.5/dx; dkz = 1./(nkz*dz); kz0 = -0.5/dz; cfgx = kiss_fft_alloc(nkx,0,NULL,NULL); cfgxi = kiss_fft_alloc(nkx,1,NULL,NULL); cfgz = kiss_fft_alloc(nkz,0,NULL,NULL); cfgzi = kiss_fft_alloc(nkz,1,NULL,NULL); uk = (kiss_fft_cpx **) sf_complexalloc2(nkx,nkz); ctracex = (kiss_fft_cpx *) sf_complexalloc(nkx); ctracez = (kiss_fft_cpx *) sf_complexalloc(nkz); wav = sf_floatalloc(nt); sf_floatread(wav,nt,source); old = sf_floatalloc2(nxb,nzb); cur = sf_floatalloc2(nxb,nzb); nxt = sf_floatalloc2(nxb,nzb); ukr = sf_floatalloc2(nxb,nzb); derold = sf_floatalloc2(nxb,nzb); dercur = sf_floatalloc2(nxb,nzb); aa = sf_floatalloc3(6,nxb,nzb); bd_init(nx,nz,nbt,nbb,nbl,nbr,ct,cb,cl,cr); vx = sf_floatalloc2(nxb,nzb); vz = sf_floatalloc2(nxb,nzb); /*input & extend velocity model*/ for (iz=nbt; iz<nz+nbt; iz++){ sf_floatread(vx[iz]+nbl,nx,velx); sf_floatread(vz[iz]+nbl,nx,velz); for (ix=0; ix<nbl; ix++){ vx[iz][ix] = vx[iz][nbl]; vz[iz][ix] = vz[iz][nbl]; } for (ix=0; ix<nbr; ix++){ vx[iz][nx+nbl+ix] = vx[iz][nx+nbl-1]; vz[iz][nx+nbl+ix] = vz[iz][nx+nbl-1]; } } for (iz=0; iz<nbt; iz++){ for (ix=0; ix<nxb; ix++){ vx[iz][ix] = vx[nbt][ix]; vz[iz][ix] = vz[nbt][ix]; } } for (iz=0; iz<nbb; iz++){ for (ix=0; ix<nxb; ix++){ vx[nz+nbt+iz][ix] = vx[nz+nbt-1][ix]; vz[nz+nbt+iz][ix] = vz[nz+nbt-1][ix]; } } vx0 =0.0; vz0 =0.0; for (iz=0; iz < nzb; iz++) { for (ix=0; ix < nxb; ix++) { vx0 += vx[iz][ix]*vx[iz][ix]; vz0 += vz[iz][ix]*vz[iz][ix]; } } vx0 = sqrtf(vx0/(nxb*nzb)); vz0 = sqrtf(vz0/(nxb*nzb)); vx02=vx0*vx0; vz02=vz0*vz0; /*input & extend anistropic model*/ yi = sf_floatalloc2(nxb,nzb); for (iz=nbt; iz<nz+nbt; iz++){ sf_floatread(yi[iz]+nbl,nx,yita); for (ix=0; ix<nbl; ix++){ yi[iz][ix] = yi[iz][nbl]; } for (ix=0; ix<nbr; ix++){ yi[iz][nx+nbl+ix] = yi[iz][nx+nbl-1]; } } for (iz=0; iz<nbt; iz++){ for (ix=0; ix<nxb; ix++){ yi[iz][ix] = yi[nbt][ix]; } } for (iz=0; iz<nbb; iz++){ for (ix=0; ix<nxb; ix++){ yi[nz+nbt+iz][ix] = yi[nz+nbt-1][ix]; } } yi0 = 0.0; for (iz=0; iz < nzb; iz++) { for (ix=0; ix < nxb; ix++) { yi0+= yi[iz][ix]*yi[iz][ix]; } } yi0 = sqrtf(yi0/(nxb*nzb)); se = sf_floatalloc2(nxb,nzb); for (iz=nbt; iz<nz+nbt; iz++){ sf_floatread(se[iz]+nbl,nx,seta); for (ix=0; ix<nbl; ix++){ se[iz][ix] = se[iz][nbl]; } for (ix=0; ix<nbr; ix++){ se[iz][nx+nbl+ix] = se[iz][nx+nbl-1]; } } for (iz=0; iz<nbt; iz++){ for (ix=0; ix<nxb; ix++){ se[iz][ix] = se[nbt][ix]; } } for (iz=0; iz<nbb; iz++){ for (ix=0; ix<nxb; ix++){ se[nz+nbt+iz][ix] = se[nz+nbt-1][ix]; } } se0 = 0.0; for (iz=0; iz < nzb; iz++) { for (ix=0; ix < nxb; ix++) { se0+= se[iz][ix]; } } se0 /= (nxb*nzb); se0 *= pi/180.0; for (iz=0; iz < nzb; iz++) { for (ix=0; ix < nxb; ix++) { se[iz][ix] *= pi/180.0; } } cosg0 = cosf(se0); cosg02 = cosg0*cosg0; sing0 = sinf(se0); sing02 = sing0*sing0; w10 = vx02*cosg02+vz02*sing02; w20 = vz02*cosg02+vx02*sing02; w30 = vx02+vz02+(vx02-vz02)*sinf(2.0*se0); h10 = sqrtf(-8.0*yi0*vx02*vz02*cosg02*sing02/(1.0+2.0*yi0)+w10*w10); h20 = sqrtf(-8.0*yi0*vx02*vz02*cosg02*sing02/(1.0+2.0*yi0)+w20*w20); h30 = sqrtf(-2.0*yi0*vx02*vz02*cosf(2.0*se0)*cosf(2.0*se0)/(1.0+2.0*yi0)+0.25*w30*w30); dt2 = dt*dt; dx2 = dx*dx; dx4 = dx2*dx2; dz2 = dz*dz; dz4 = dz2*dz2; for (iz=0; iz < nzb; iz++){ for (ix=0; ix < nxb; ix++) { vx2 = vx[iz][ix]*vx[iz][ix]; vz2 = vz[iz][ix]*vz[iz][ix]; cosg = cosf(se[iz][ix]); sing = sinf(se[iz][ix]); cosg2 = cosg*cosg; sing2 = sing*sing; w1 = vx2*cosg2+vz2*sing2; w2 = vz2*cosg2+vx2*sing2; w3 = vx2+vz2+(vx2-vz2)*sinf(2.0*se[iz][ix]); h1 = sqrtf(-8.0*yi[iz][ix]*vx2*vz2*cosg2*sing2/(1.0+2.0*yi[iz][ix])+w1*w1); h2 = sqrtf(-8.0*yi[iz][ix]*vx2*vz2*cosg2*sing2/(1.0+2.0*yi[iz][ix])+w2*w2); h3 = sqrtf(-2.0*yi[iz][ix]*vx2*vz2*cosf(2.0*se[iz][ix])*cosf(2.0*se[iz][ix])/(1.0+2.0*yi[iz][ix])+0.25*w3*w3); aa[iz][ix][4] = (w1+h1)*(dt2+(2.0*dx2-dt2*(w1+h1))/(w10+h10))/(24.0*dx4); aa[iz][ix][5] = (w2+h2)*(dt2+(2.0*dz2-dt2*(w2+h2))/(w20+h20))/(24.0*dz4); aa[iz][ix][3] = -aa[iz][ix][4]*dx2/dz2-aa[iz][ix][5]*dz2/dx2+(dt2*(w3+2.0*h3)+dx2*(w1+h1)/(w10+h10)+dz2*(w2+h2)/(w20+h20)-dt2*(w3+2.0*h3)*(w3+2.0*h3)/(w30+2.0*h30))/(12.0*dx2*dz2); aa[iz][ix][1] = -2.0*aa[iz][ix][3]-4.0*aa[iz][ix][4]-(w1+h1)/(dx2*(w10+h10)); aa[iz][ix][2] = -2.0*aa[iz][ix][3]-4.0*aa[iz][ix][5]-(w2+h2)/(dz2*(w20+h20)); aa[iz][ix][0] = -2.0*aa[iz][ix][1]-2.0*aa[iz][ix][2]-4.0*aa[iz][ix][3]-2.0*aa[iz][ix][4]-2.0*aa[iz][ix][5]; } } for (iz=0; iz < nzb; iz++) { for (ix=0; ix < nxb; ix++) { cur[iz][ix] = 0.0; } } cur[isz+nbt][isx+nbl] = wav[0]; for (iz=0; iz < nzb; iz++) { for (ix=0; ix < nxb; ix++) { old[iz][ix] = 0.0; derold[iz][ix] =cur[iz][ix]/dt; } } for (iz=nbt; iz<nz+nbt; iz++){ sf_floatwrite(cur[iz]+nbl,nx,out); } /* #ifdef _OPENMP #pragma omp parallel {nth = omp_get_num_threads();} sf_warning("using %d threads",nth); #endif */ /* propagation in time */ for (it=1; it < nt; it++) { for (iz=0; iz < nzb; iz++){ for (ix=0; ix < nxb; ix++){ nxt[iz][ix] = 0.0; uk[iz][ix].r = cur[iz][ix]; uk[iz][ix].i = 0.0; } } /* compute u(kx,kz) */ for (iz=0; iz < nzb; iz++){ /* Fourier transform x to kx */ for (ix=1; ix < nxb; ix+=2){ uk[iz][ix] = sf_cneg(uk[iz][ix]); } kiss_fft_stride(cfgx,uk[iz],ctracex,1); for (ikx=0; ikx<nkx; ikx++) uk[iz][ikx] = ctracex[ikx]; } for (ikx=0; ikx < nkx; ikx++){ /* Fourier transform z to kz */ for (ikz=1; ikz<nkz; ikz+=2){ uk[ikz][ikx] = sf_cneg(uk[ikz][ikx]); } kiss_fft_stride(cfgz,uk[0]+ikx,ctracez,nkx); for (ikz=0; ikz<nkz; ikz++) uk[ikz][ikx] = ctracez[ikz]; } /* #ifdef _OPENMP #pragma omp parallel for private(ik,ix,x,k,tmp,tmpex,tmpdt) #endif */ for (ikz=0; ikz < nkz; ikz++) { kz1 = (kz0+ikz*dkz)*2.0*pi; for (ikx=0; ikx < nkx; ikx++) { kx1 = (kx0+ikx*dkx)*2.0*pi; kx = kx1*cosg0+kz1*sing0; kz = kz1*cosg0-kx1*sing0; tmpvk = (vx02*kx*kx+vz02*kz*kz); k2 = kx1*kx1+kz1*kz1; vk2 = 0.5*tmpvk+0.5*sqrtf(tmpvk*tmpvk-8.0*yi0/(1.0+2.0*yi0)*vx02*vz02*kx*kx*kz*kz); vk = sqrtf(vk2); tmpdt = 2.0*(cosf(vk*dt)-1.0); if(!k2) tmpdt /=(k2+err); else tmpdt /= (k2); uk[ikz][ikx] = sf_crmul(uk[ikz][ikx],tmpdt); } } /* Inverse FFT*/ for (ikx=0; ikx < nkx; ikx++){ /* Inverse Fourier transform kz to z */ kiss_fft_stride(cfgzi,(kiss_fft_cpx *)uk[0]+ikx,(kiss_fft_cpx *)ctracez,nkx); for (ikz=0; ikz < nkz; ikz++) uk[ikz][ikx] = sf_crmul(ctracez[ikz],ikz%2?-1.0:1.0); } for (ikz=0; ikz < nkz; ikz++){ /* Inverse Fourier transform kx to x */ kiss_fft_stride(cfgxi,(kiss_fft_cpx *)uk[ikz],(kiss_fft_cpx *)ctracex,1); for (ikx=0; ikx < nkx; ikx++) uk[ikz][ikx] = sf_crmul(ctracex[ikx],ikx%2?-1.0:1.0); } for (iz=0; iz < nzb; iz++){ for (ix=0; ix < nxb; ix++){ ukr[iz][ix] = sf_crealf(uk[iz][ix]); ukr[iz][ix] /= (nkx*nkz); } } for (iz=2; iz < nzb-2; iz++) { for (ix=2; ix < nxb-2; ix++) { nxt[iz][ix] = ukr[iz][ix]*aa[iz][ix][0] + (ukr[iz][ix-1]+ukr[iz][ix+1])*aa[iz][ix][1] + (ukr[iz-1][ix]+ukr[iz+1][ix])*aa[iz][ix][2] + (ukr[iz-1][ix-1]+ukr[iz-1][ix+1]+ukr[iz+1][ix-1]+ukr[iz+1][ix+1])*aa[iz][ix][3] + (ukr[iz][ix-2]+ukr[iz][ix+2])*aa[iz][ix][4] + (ukr[iz-2][ix]+ukr[iz+2][ix])*aa[iz][ix][5]; } } /* nxt[0][0] = uk[0][0]*aa[0][0][0] + uk[0][1]*aa[0][0][1] + uk[1][0]*aa[0][0][2]; nxt[0][nxb-1] = uk[0][nxb-1]*aa[0][nxb-1][0] + uk[0][nxb-2]*aa[0][nxb-1][1] + uk[1][nxb-1]*aa[0][nxb-1][2]; nxt[nzb-1][0] = uk[nzb-1][0]*aa[nzb-1][0][0] + uk[nzb-1][1]*aa[nzb-1][0][1] + uk[nzb-2][0]*aa[nzb-1][0][2]; nxt[nzb-1][nxb-1] = uk[nzb-1][nxb-1]*aa[nzb-1][nxb-1][0] + uk[nzb-1][nxb-2]*aa[nzb-1][nxb-1][1] + uk[nzb-2][nxb-1]*aa[nzb-1][nxb-1][2]; for (ix=1; ix < nxb-1; ix++) { nxt[0][ix] = uk[0][ix]*aa[0][ix][0] + (uk[0][ix-1]+uk[0][ix+1])*aa[0][ix][1] + uk[1][ix]*aa[0][ix][2]; nxt[nz-1][ix] = uk[nz-1][ix]*aa[nz-1][ix][0] + (uk[nz-1][ix-1]+uk[nz-1][ix+1])*aa[nz-1][ix][1] + uk[nz-2][ix]*aa[nz-1][ix][2]; } for (iz=1; iz < nzb-1; iz++) { nxt[iz][0] = uk[iz][0]*aa[iz][0][0] + uk[iz][1]*aa[iz][0][1] + (uk[iz-1][0]+uk[iz+1][0])*aa[iz][0][2]; nxt[iz][nx-1] = uk[iz][nx-1]*aa[iz][nx-1][0] + uk[iz][nx-2]*aa[iz][nx-1][1] + (uk[iz-1][nx-1]+uk[iz+1][nx-1])*aa[iz][nx-1][2]; } */ // nxt[isz+nbt][isx+nbl] += wav[it]; for (iz=0; iz < nzb; iz++) { for (ix=0; ix < nxb; ix++) { dercur[iz][ix]= derold[iz][ix] + nxt[iz][ix]/dt; nxt[iz][ix] = cur[iz][ix] + dercur[iz][ix]*dt; // nxt[iz][ix] += 2.0*cur[iz][ix] -old[iz][ix]; } } nxt[isz+nbt][isx+nbl] += wav[it]; bd_decay(nxt); bd_decay(dercur); for (iz=0; iz < nzb; iz++) { for(ix=0; ix < nxb; ix++) { old[iz][ix] = cur[iz][ix]; cur[iz][ix] = nxt[iz][ix]; derold[iz][ix] = dercur[iz][ix]; } } for (iz=nbt; iz<nz+nbt; iz++){ sf_floatwrite(nxt[iz]+nbl,nx,out); } } bd_close(); free(**aa); free(*aa); free(aa); free(*vx); free(*vz); free(*yi); free(*se); free(*nxt); free(*cur); free(*old); free(*dercur); free(*derold); free(*uk); free(*ukr); free(vx); free(vz); free(yi); free(se); free(nxt); free(cur); free(old); free(dercur); free(derold); free(uk); free(ukr); // sf_fileclose(vel); // sf_fileclose(inp); // sf_fileclose(out); exit(0); }
BlurayMetadata::~BlurayMetadata() { if (m_bdnav) bd_close(m_bdnav); }
static void bdmv_metadata_thread (GSimpleAsyncResult *result, GObject *object, GCancellable *cancellable) { BLURAY *bd; META_DL *meta; GError *error; GFile *file; char *disc_root; char *icon; char *name; const char *lang; file = G_FILE (object); disc_root = g_file_get_path (file); bd = bd_open (disc_root, NULL); g_free (disc_root); if (bd == NULL) { error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "Device is not a Blu-Ray disc"); goto error; } lang = get_iso_639_3_for_locale (); if (lang != NULL) bd_set_player_setting_str (bd, BLURAY_PLAYER_SETTING_MENU_LANG, lang); meta = bd_get_meta (bd); if (meta == NULL) { error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, "Device is not a Blu-Ray disc, or has no metadata"); bd_close (bd); goto error; } name = icon = NULL; if (meta != NULL) { if (meta->di_name && *meta->di_name) name = g_strdup (meta->di_name); icon = g_strdup (get_icon (meta)); } /* We're missing either an icon, or the name */ if (!name || !icon) { bd_set_player_setting_str (bd, BLURAY_PLAYER_SETTING_MENU_LANG, "eng"); meta = bd_get_meta (bd); if (meta != NULL && name == NULL && meta->di_name && *meta->di_name) name = meta->di_name; if (meta != NULL && icon == NULL) icon = g_strdup (get_icon (meta)); } /* Set the results */ if (icon != NULL) { char *icon_path; GFile *icon_file; icon_path = g_strdup_printf ("BDMV/META/DL/%s", icon); g_free (icon); icon_file = g_file_resolve_relative_path (file, icon_path); g_free (icon_path); g_simple_async_result_set_op_res_gpointer (result, g_file_icon_new (icon_file), NULL); } else { g_simple_async_result_set_op_res_gpointer (result, NULL, NULL); } if (name != NULL) g_object_set_data_full (G_OBJECT (result), "name", name, g_free); bd_close (bd); return; error: g_simple_async_result_set_from_error (result, error); g_simple_async_result_set_op_res_gpointer (result, NULL, NULL); g_error_free (error); }
int main(int argc, char *argv[]) { int title_no = -1; int playlist = -1; int angle = 0; char *bdpath = NULL, *dest = NULL; FILE *out; int opt; int verbose = 0; int64_t total = 0; int64_t pos, end_pos = -1; size_t size, wrote; int bytes; int title_count; BLURAY *bd; int chapter_start = 0; int chapter_end = -1; uint8_t buf[BUF_SIZE]; char *keyfile = NULL; BLURAY_TITLE_INFO *ti; do { opt = getopt(argc, argv, OPTS); switch (opt) { case -1: if (optind < argc && bdpath == NULL) { bdpath = argv[optind]; optind++; opt = 1; } else if (optind < argc && dest == NULL) { dest = argv[optind]; optind++; opt = 1; } break; case 'c': { int match; match = sscanf(optarg, "%d-%d", &chapter_start, &chapter_end); if (match == 1) { chapter_end = chapter_start + 1; } chapter_start--; chapter_end--; } break; case 'k': keyfile = optarg; break; case 'a': angle = atoi(optarg); angle--; break; case 't': if (playlist >= 0) { _usage(argv[0]); } title_no = atoi(optarg); title_no--; break; case 'p': if (title_no >= 0) { _usage(argv[0]); } playlist = atoi(optarg); break; case 'v': verbose = 1; break; default: _usage(argv[0]); break; } } while (opt != -1); if (title_no < 0 && playlist < 0) { _usage(argv[0]); } if (optind < argc) { _usage(argv[0]); } bd = bd_open(bdpath, keyfile); if (bd == NULL) { fprintf(stderr, "Failed to open disc: %s\n", bdpath); return 1; } title_count = bd_get_titles(bd, TITLES_RELEVANT, 0); if (title_count <= 0) { fprintf(stderr, "No titles found: %s\n", bdpath); return 1; } if (title_no >= 0) { if (!bd_select_title(bd, title_no)) { fprintf(stderr, "Failed to open title: %d\n", title_no); return 1; } ti = bd_get_title_info(bd, title_no, angle); } else { if (!bd_select_playlist(bd, playlist)) { fprintf(stderr, "Failed to open playlist: %d\n", playlist); return 1; } ti = bd_get_playlist_info(bd, playlist, angle); } if (dest) { out = fopen(dest, "wb"); if (out == NULL) { fprintf(stderr, "Failed to open destination: %s\n", dest); return 1; } } else { out = stdout; } if (angle >= (int)ti->angle_count) { fprintf(stderr, "Invalid angle %d > angle count %d. Using angle 1.\n", angle+1, ti->angle_count); angle = 0; } bd_select_angle(bd, angle); if (chapter_start >= (int)ti->chapter_count) { fprintf(stderr, "First chapter %d > chapter count %d\n", chapter_start+1, ti->chapter_count); return 1; } if (chapter_end >= (int)ti->chapter_count) { chapter_end = -1; } if (chapter_end >= 0) { end_pos = bd_chapter_pos(bd, chapter_end); } bd_free_title_info(ti); bd_seek_chapter(bd, chapter_start); pos = bd_tell(bd); while (end_pos < 0 || pos < end_pos) { size = BUF_SIZE; if (size > (size_t)(end_pos - pos)) { size = end_pos - pos; } bytes = bd_read(bd, buf, size); if (bytes <= 0) { break; } pos = bd_tell(bd); wrote = fwrite(buf, 1, bytes, out); if (wrote != (size_t)bytes) { fprintf(stderr, "read/write sizes do not match: %d/%zu\n", bytes, wrote); } if (wrote == 0) { if (ferror(out)) { perror("Write error"); } break; } total += wrote; } if (verbose) { fprintf(stderr, "Wrote %"PRId64" bytes\n", total); } bd_close(bd); fclose(out); return 0; }
bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms) { safefilename = lfilename; filename = lfilename; // clean path filename QString filename = QDir(QDir::cleanPath(lfilename)).canonicalPath(); if (filename.isEmpty()) { LOG(VB_GENERAL, LOG_ERR, LOC + QString("%1 nonexistent").arg(lfilename)); filename = lfilename; } safefilename = filename; LOG(VB_GENERAL, LOG_INFO, LOC + QString("Opened BDRingBuffer device at %1") .arg(filename)); // Ask mythiowrapper to update this object on file open progress. Opening // a bluray disc can involve opening several hundred files which can take // several minutes when the disc structure is remote. The callback allows // us to 'kick' the main UI - as the 'please wait' widget is still visible // at this stage mythfile_open_register_callback(filename.toLocal8Bit().data(), this, file_opened_callback); QMutexLocker locker(&m_infoLock); rwlock.lockForWrite(); if (bdnav) close(); QString keyfile = QString("%1/KEYDB.cfg").arg(GetConfDir()); QByteArray keyarray = keyfile.toLatin1(); const char *keyfilepath = keyarray.data(); bdnav = bd_open(filename.toLocal8Bit().data(), keyfilepath); if (!bdnav) { lastError = tr("Could not open Blu-ray device: %1").arg(filename); rwlock.unlock(); mythfile_open_register_callback(filename.toLocal8Bit().data(), this, NULL); return false; } const meta_dl *metaDiscLibrary = bd_get_meta(bdnav); if (metaDiscLibrary) { LOG(VB_GENERAL, LOG_INFO, LOC + QString("Disc Title: %1 (%2)") .arg(metaDiscLibrary->di_name) .arg(metaDiscLibrary->language_code)); LOG(VB_GENERAL, LOG_INFO, LOC + QString("Alternative Title: %1") .arg(metaDiscLibrary->di_alternative)); LOG(VB_GENERAL, LOG_INFO, LOC + QString("Disc Number: %1 of %2") .arg(metaDiscLibrary->di_set_number) .arg(metaDiscLibrary->di_num_sets)); } // Check disc to see encryption status, menu and navigation types. m_topMenuSupported = false; m_firstPlaySupported = false; const BLURAY_DISC_INFO *discinfo = bd_get_disc_info(bdnav); // The following settings affect HDMV navigation // (default audio track selection, // parental controls, menu language, etc. They are not yet used. // Set parental level "age" to 99 for now. TODO: Add support for FE level bd_set_player_setting(bdnav, BLURAY_PLAYER_SETTING_PARENTAL, 99); // Set preferred language to FE guide language const char *langpref = gCoreContext->GetSetting( "ISO639Language0", "eng").toLatin1().data(); QString QScountry = gCoreContext->GetLocale()->GetCountryCode().toLower(); const char *country = QScountry.toLatin1().data(); bd_set_player_setting_str( bdnav, BLURAY_PLAYER_SETTING_AUDIO_LANG, langpref); // Set preferred presentation graphics language to the FE guide language bd_set_player_setting_str(bdnav, BLURAY_PLAYER_SETTING_PG_LANG, langpref); // Set preferred menu language to the FE guide language bd_set_player_setting_str(bdnav, BLURAY_PLAYER_SETTING_MENU_LANG, langpref); // Set player country code via MythLocale. (not a region setting) bd_set_player_setting_str( bdnav, BLURAY_PLAYER_SETTING_COUNTRY_CODE, country); int regioncode = 0; regioncode = gCoreContext->GetNumSetting("BlurayRegionCode"); if (regioncode > 0) bd_set_player_setting(bdnav, BLURAY_PLAYER_SETTING_REGION_CODE, regioncode); LOG(VB_GENERAL, LOG_INFO, LOC + QString("Using %1 as keyfile...") .arg(QString(keyfilepath))); // Return an index of relevant titles (excludes dupe clips + titles) LOG(VB_GENERAL, LOG_INFO, LOC + "Retrieving title list (please wait)."); m_numTitles = bd_get_titles(bdnav, TITLES_RELEVANT, 30); LOG(VB_GENERAL, LOG_INFO, LOC + QString("Found %1 titles.").arg(m_numTitles)); if (!m_numTitles) { // no title, no point trying any longer bd_close(bdnav); bdnav = NULL; lastError = tr("Unable to find any Blu-ray compatible titles"); rwlock.unlock(); mythfile_open_register_callback(filename.toLocal8Bit().data(), this, NULL); return false; } if (discinfo) { m_topMenuSupported = discinfo->top_menu_supported; m_firstPlaySupported = discinfo->first_play_supported; LOG(VB_PLAYBACK, LOG_INFO, LOC + "*** Blu-ray Disc Information ***"); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("First Play Supported: %1") .arg(discinfo->first_play_supported ? "yes" : "no")); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Top Menu Supported: %1") .arg(discinfo->top_menu_supported ? "yes" : "no")); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Number of HDMV Titles: %1") .arg(discinfo->num_hdmv_titles)); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Number of BD-J Titles: %1") .arg(discinfo->num_bdj_titles)); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("Number of Unsupported Titles: %1") .arg(discinfo->num_unsupported_titles)); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("AACS present on disc: %1") .arg(discinfo->aacs_detected ? "yes" : "no")); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("libaacs used: %1") .arg(discinfo->libaacs_detected ? "yes" : "no")); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("AACS handled: %1") .arg(discinfo->aacs_handled ? "yes" : "no")); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("BD+ present on disc: %1") .arg(discinfo->bdplus_detected ? "yes" : "no")); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("libbdplus used: %1") .arg(discinfo->libbdplus_detected ? "yes" : "no")); LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("BD+ handled: %1") .arg(discinfo->bdplus_handled ? "yes" : "no")); } m_mainTitle = 0; m_currentTitleLength = 0; m_titlesize = 0; m_currentTime = 0; m_currentTitleInfo = NULL; m_currentTitleAngleCount = 0; // Mostly event-driven values below m_currentAngle = 0; m_currentTitle = 0; m_currentPlaylist = 0; m_currentPlayitem = 0; m_currentChapter = 0; m_currentAudioStream = 0; m_currentIGStream = 0; m_currentPGTextSTStream = 0; m_currentSecondaryAudioStream = 0; m_currentSecondaryVideoStream = 0; m_PGTextSTEnabled = false; m_secondaryAudioEnabled = false; m_secondaryVideoEnabled = false; m_secondaryVideoIsFullscreen = false; m_stillMode = BLURAY_STILL_NONE; m_stillTime = 0; m_inMenu = false; // First, attempt to initialize the disc in HDMV navigation mode. // If this fails, fall back to the traditional built-in title switching // mode. if (m_tryHDMVNavigation && m_firstPlaySupported && bd_play(bdnav)) { LOG(VB_GENERAL, LOG_INFO, LOC + "Using HDMV navigation mode."); m_isHDMVNavigation = true; // Register the Menu Overlay Callback bd_register_overlay_proc(bdnav, this, HandleOverlayCallback); } else { LOG(VB_GENERAL, LOG_INFO, LOC + "Using title navigation mode."); // Loop through the relevant titles and find the longest uint64_t titleLength = 0; BLURAY_TITLE_INFO *titleInfo = NULL; bool found = false; for( unsigned i = 0; i < m_numTitles; ++i) { titleInfo = GetTitleInfo(i); if (!titleInfo) continue; if (titleLength == 0 || (titleInfo->duration > titleLength)) { m_mainTitle = titleInfo->idx; titleLength = titleInfo->duration; found = true; } } if (!found) { // no title, no point trying any longer bd_close(bdnav); bdnav = NULL; lastError = tr("Unable to find any usable Blu-ray titles"); rwlock.unlock(); mythfile_open_register_callback(filename.toLocal8Bit().data(), this, NULL); return false; } SwitchTitle(m_mainTitle); } readblocksize = BD_BLOCK_SIZE * 62; setswitchtonext = false; ateof = false; commserror = false; numfailures = 0; rawbitrate = 8000; CalcReadAheadThresh(); rwlock.unlock(); mythfile_open_register_callback(filename.toLocal8Bit().data(), this, NULL); return true; }
static int bluray_stream_open(stream_t *s, int mode, void *opts, int *file_format) { struct stream_priv_s *p = opts; struct bluray_priv_s *b; BLURAY_TITLE_INFO *info = NULL; BLURAY *bd; int title, title_guess, title_count; uint64_t title_size; unsigned int angle = 0; uint64_t max_duration = 0; char *device = NULL; int i; /* find the requested device */ if (p->device) device = p->device; else if (bluray_device) device = bluray_device; if (!device) { mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_BlurayNoDevice); return STREAM_UNSUPPORTED; } /* open device */ bd = bd_open(device, NULL); if (!bd) { mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_CantOpenBluray, device); return STREAM_UNSUPPORTED; } /* check for available titles on disc */ title_count = bd_get_titles(bd, TITLES_RELEVANT, angle); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_TITLES=%d\n", title_count); if (!title_count) { mp_msg(MSGT_OPEN, MSGL_ERR, MSGTR_BlurayNoTitles); bd_close(bd); return STREAM_UNSUPPORTED; } /* parse titles information */ title_guess = BLURAY_DEFAULT_TITLE; for (i = 0; i < title_count; i++) { BLURAY_TITLE_INFO *ti; int sec, msec; ti = bd_get_title_info(bd, i, angle); if (!ti) continue; sec = ti->duration / 90000; msec = (ti->duration - sec) % 1000; mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_TITLE_%d_CHAPTERS=%d\n", i + 1, ti->chapter_count); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_TITLE_%d_ANGLE=%d\n", i + 1, ti->angle_count); mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_BLURAY_TITLE_%d_LENGTH=%d.%03d\n", i + 1, sec, msec); mp_msg(MSGT_IDENTIFY, MSGL_V, "ID_BLURAY_TITLE_%d_PLAYLIST=%05d\n", i + 1, ti->playlist); /* try to guess which title may contain the main movie */ if (ti->duration > max_duration) { max_duration = ti->duration; title_guess = i; } bd_free_title_info(ti); } /* Select current title */ title = p->title ? p->title - 1: title_guess; title = FFMIN(title, title_count - 1); bd_select_title(bd, title); title_size = bd_get_title_size(bd); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_CURRENT_TITLE=%d\n", title + 1); /* Get current title information */ info = bd_get_title_info(bd, title, angle); if (!info) goto err_no_info; /* Select angle */ angle = bluray_angle ? bluray_angle : BLURAY_DEFAULT_ANGLE; angle = FFMIN(angle, info->angle_count); if (angle) bd_select_angle(bd, angle); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_BLURAY_CURRENT_ANGLE=%d\n", angle + 1); bd_free_title_info(info); err_no_info: s->fill_buffer = bluray_stream_fill_buffer; s->seek = bluray_stream_seek; s->close = bluray_stream_close; s->control = bluray_stream_control; b = calloc(1, sizeof(struct bluray_priv_s)); b->bd = bd; b->current_angle = angle; b->current_title = title; s->end_pos = title_size; s->sector_size = BLURAY_SECTOR_SIZE; s->flags = mode | MP_STREAM_SEEK; s->priv = b; s->type = STREAMTYPE_BLURAY; s->url = strdup("br://"); mp_msg(MSGT_OPEN, MSGL_V, "Blu-ray successfully opened.\n"); return STREAM_OK; }
int BD_Parser(FILE *fp, FileInfo *finfo, int is_dir) { int nRet = 0; int ii; int title_guess, title_count; uint64_t max_duration = 0; uint64_t max_duration2 = 0; MPLS_PL * pl = NULL, * pl2 = NULL, * def_pl; BLURAY *bd = NULL; parse_priv * par_priv = NULL; BLURAY_TITLE_MAX_DUR *title_max = NULL; int title_id[2] = {-1}; int mpls_id[2] = {-1}; mp_msg("BD_Parser\n"); if (finfo->priv != NULL) { par_priv = (parse_priv *)finfo->priv; bd = par_priv->bd; title_count = par_priv->title_num; free(par_priv); finfo->priv = NULL; } else { bd = bd_open(finfo->filepath, NULL); if (bd) title_count = bd_get_titles(bd, TITLES_RELEVANT); } //goto error_end; if (bd) { title_max = bd_get_title_max2_dur(bd); if (title_max != NULL) { pl = bd_title_filter(bd, title_max->dur_first_count, title_max->dur_first, is_dir, finfo->filepath, &title_id[0], &mpls_id[0]); if (title_max->dur_second_count > 0) { pl2 = bd_title_filter(bd, title_max->dur_second_count, title_max->dur_second, is_dir, finfo->filepath, &title_id[1], &mpls_id[1]); } mp_msg("title_id: %d %d, mpls_id: %d %d\n", title_id[0], title_id[1], mpls_id[0], mpls_id[1]); title_guess = title_id[0]; bd_free_title_max2_dur(title_max); } def_pl = pl; //if (pl2 != NULL) if (pl2 != NULL && pl != NULL) { MPLS_PI *pi, *pi2; pi = &pl->play_item[0]; pi2 = &pl2->play_item[0]; mp_msg("playlist 1: c: %d, v: %d, a: %d, s: %d, d: %d\n", bd_get_chapters(pl), pi->stn.num_video, pi->stn.num_audio, pi->stn.num_pg, _pl_duration(pl)/45000); mp_msg("playlist 2: c: %d, v: %d, a: %d, s: %d, d: %d\n", bd_get_chapters(pl2), pi2->stn.num_video, pi2->stn.num_audio, pi2->stn.num_pg, _pl_duration(pl2)/45000); if ((bd_get_chapters(pl) < bd_get_chapters(pl2)) && (pi->stn.num_audio <= pi2->stn.num_audio) ) { // playlist 2 have more chapters and audio use it. def_pl = pl2; title_guess = title_id[1]; } else { if ((pl->list_count > 0) && (pl2->list_count > 0)) { if ( (pi2->stn.num_audio >= pi->stn.num_audio) && (pi2->stn.num_pg > pi->stn.num_pg) && (bd_get_chapters(pl2) >= bd_get_chapters(pl)) ) //Barry 2011-07-29 fix mantis: 5605 { def_pl = pl2; title_guess = title_id[1]; } #if 1 //Barry 2011-07-13 fix mantis: 5192 if ((_pl_duration(pl)/45000) > 60000) { def_pl = pl2; title_guess = title_id[1]; } #endif } } } else if (pl2 != NULL && pl == NULL) { // playlist 2 have more chapters and audio use it. def_pl = pl2; title_guess = title_id[1]; //printf("*********** Switch to playlist 2 **********\n"); } nRet = set_mpls_info(def_pl, finfo); if (nRet == 1) { MPLS_PI *pi; int chapters = bd_get_chapters(def_pl); ((bd_priv_t *)finfo->priv)->chapter_num = chapters; ((bd_priv_t *)finfo->priv)->title = title_guess; pi = &def_pl->play_item[0]; if (pi != NULL) ((bd_priv_t *)finfo->priv)->file_id = atoi(pi->clip[0].clip_id); } error_end: if (pl != NULL) mpls_free(pl); if (pl2 != NULL) mpls_free(pl2); if (bd != NULL) bd_close(bd); } return nRet; }
int main(int argc, char *argv[]) { BLURAY *bd; int count, ii, opt; unsigned int seconds = 0; unsigned int flags = TITLES_RELEVANT; char *bd_dir = NULL; BD_DEBUG(DBG_BLURAY,"\nListing titles:\n"); do { opt = getopt(argc, argv, OPTS); switch (opt) { case -1: if (optind < argc && bd_dir == NULL) { bd_dir = argv[optind]; optind++; opt = 1; } break; case 'a': flags = TITLES_ALL; break; case 's': seconds = strtol(optarg, NULL, 0); break; case 'h': default: _usage(argv[0]); break; } } while (opt != -1); if (bd_dir == NULL) { _usage(argv[0]); } bd = bd_open(bd_dir, NULL); count = bd_get_titles(bd, flags, seconds); for (ii = 0; ii < count; ii++) { BLURAY_TITLE_INFO* ti; ti = bd_get_title_info(bd, ii, 0); printf( "index: %d duration: %02"PRIu64":%02"PRIu64":%02"PRIu64" chapters: %3d angles: %2u clips: %3u (playlist: %05d.mpls) " "V:%d A:%-2d PG:%-2d IG:%-2d SV:%d SA:%d\n", ii + 1, (ti->duration / 90000) / (3600), ((ti->duration / 90000) % 3600) / 60, ((ti->duration / 90000) % 60), ti->chapter_count, ti->angle_count, ti->clip_count, ti->playlist, ti->clips[0].video_stream_count, ti->clips[0].audio_stream_count, ti->clips[0].pg_stream_count, ti->clips[0].ig_stream_count, ti->clips[0].sec_video_stream_count, ti->clips[0].sec_audio_stream_count ); bd_free_title_info(ti); } bd_close(bd); return 0; }
bool BDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms) { VERBOSE(VB_IMPORTANT, LOC + QString("Opened BDRingBuffer device at %1") .arg(lfilename.toLatin1().data())); rwlock.lockForWrite(); if (bdnav) { if (m_currentTitleInfo) bd_free_title_info(m_currentTitleInfo); bd_close(bdnav); bdnav = NULL; } filename = lfilename; QString keyfile = QString("%1/KEYDB.cfg").arg(GetConfDir()); QByteArray keyarray = keyfile.toAscii(); const char *keyfilepath = keyarray.data(); bdnav = bd_open(lfilename.toLatin1().data(), keyfilepath); if (!bdnav) { rwlock.unlock(); return false; } // Check disc to see encryption status, menu and navigation types. const BLURAY_DISC_INFO *discinfo = bd_get_disc_info(bdnav); if (discinfo) { VERBOSE(VB_PLAYBACK, QString( "*** Blu-ray Disc Information ***\n" "First Play Supported: %1\n" "Top Menu Supported: %2\n" "Number of HDMV Titles: %3\n" "Number of BD-J Titles: %4\n" "Number of Unsupported Titles: %5\n" "AACS present on disc: %6\n" "libaacs used: %7\n" "AACS handled: %8\n" "BD+ present on disc: %9\n" "libbdplus used: %10\n" "BD+ handled: %11") .arg(discinfo->first_play_supported ? "yes" : "no") .arg(discinfo->top_menu_supported ? "yes" : "no") .arg(discinfo->num_hdmv_titles) .arg(discinfo->num_bdj_titles) .arg(discinfo->num_unsupported_titles) .arg(discinfo->aacs_detected ? "yes" : "no") .arg(discinfo->libaacs_detected ? "yes" : "no") .arg(discinfo->aacs_handled ? "yes" : "no") .arg(discinfo->bdplus_detected ? "yes" : "no") .arg(discinfo->libbdplus_detected ? "yes" : "no") .arg(discinfo->bdplus_handled ? "yes" : "no")); } // The following settings affect HDMV navigation // (default audio track selection, // parental controls, menu language, etc. They are not yet used. // Set parental level "age" to 99 for now. TODO: Add support for FE level bd_set_player_setting(bdnav, BLURAY_PLAYER_SETTING_PARENTAL, 99); // Set preferred language to FE guide language const char *langpref = gCoreContext->GetSetting( "ISO639Language0", "eng").toLatin1().data(); QString QScountry = gCoreContext->GetLocale()->GetCountryCode().toLower(); const char *country = QScountry.toLatin1().data(); bd_set_player_setting_str( bdnav, BLURAY_PLAYER_SETTING_AUDIO_LANG, langpref); // Set preferred presentation graphics language to the FE guide language bd_set_player_setting_str(bdnav, BLURAY_PLAYER_SETTING_PG_LANG, langpref); // Set preferred menu language to the FE guide language bd_set_player_setting_str(bdnav, BLURAY_PLAYER_SETTING_MENU_LANG, langpref); // Set player country code via MythLocale. (not a region setting) bd_set_player_setting_str( bdnav, BLURAY_PLAYER_SETTING_COUNTRY_CODE, country); int regioncode = 0; regioncode = gCoreContext->GetNumSetting("BlurayRegionCode"); if (regioncode > 0) bd_set_player_setting(bdnav, BLURAY_PLAYER_SETTING_REGION_CODE, regioncode); VERBOSE(VB_IMPORTANT, LOC + QString("Using %1 as keyfile...") .arg(QString(keyfilepath))); // Return an index of relevant titles (excludes dupe clips + titles) m_numTitles = bd_get_titles(bdnav, TITLES_RELEVANT); m_mainTitle = 0; m_currentTitleLength = 0; m_titlesize = 0; m_currentTime = 0; m_currentTitleInfo = NULL; m_currentTitleAngleCount = 0; // Mostly event-driven values below m_currentAngle = 0; m_currentTitle = 0; m_currentPlaylist = 0; m_currentPlayitem = 0; m_currentChapter = 0; m_currentAudioStream = 0; m_currentIGStream = 0; m_currentPGTextSTStream = 0; m_currentSecondaryAudioStream = 0; m_currentSecondaryVideoStream = 0; m_PGTextSTEnabled = false; m_secondaryAudioEnabled = false; m_secondaryVideoEnabled = false; m_secondaryVideoIsFullscreen = false; m_still = 0; m_inMenu = false; VERBOSE(VB_IMPORTANT, LOC + QString("Found %1 relevant titles.") .arg(m_numTitles)); // Loop through the relevant titles and find the longest uint64_t titleLength = 0; uint64_t margin = 90000 << 4; // approx 30s BLURAY_TITLE_INFO *titleInfo = NULL; for( unsigned i = 0; i < m_numTitles; ++i) { titleInfo = bd_get_title_info(bdnav, i); if (titleLength == 0 || (titleInfo->duration > (titleLength + margin))) { m_mainTitle = titleInfo->idx; titleLength = titleInfo->duration; } } bd_free_title_info(titleInfo); SwitchTitle(m_mainTitle); #if 0 // First, attempt to initialize the disc in HDMV navigation mode. // If this fails, fall back to the traditional built-in title switching // mode. if (bd_play(bdnav)) { m_is_hdmv_navigation = true; // Initialize the HDMV event queue HandleBDEvents(); // Register the Menu Overlay Callback bd_register_overlay_proc(bdnav, this, HandleOverlayCallback); } #endif readblocksize = BD_BLOCK_SIZE * 62; setswitchtonext = false; ateof = false; commserror = false; numfailures = 0; rawbitrate = 8000; CalcReadAheadThresh(); rwlock.unlock(); return true; }