int BDRingBuffer::safe_read(void *data, uint sz) { int result = 0; if (m_isHDMVNavigation) { HandleBDEvents(); while (result == 0) { BD_EVENT event; result = bd_read_ext(bdnav, (unsigned char *)data, sz, &event); HandleBDEvent(event); if (result == 0) HandleBDEvents(); } } else { result = bd_read(bdnav, (unsigned char *)data, sz); } m_currentTime = bd_tell(bdnav); return result; }
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; }