std::vector<BLURAY_TITLE_INFO*> CBlurayDirectory::GetUserPlaylists() { std::string root = m_url.GetHostName(); std::string discInfPath = URIUtils::AddFileToFolder(root, "disc.inf"); std::vector<BLURAY_TITLE_INFO*> userTitles; CFile file; char buffer[1025]; if (file.Open(discInfPath)) { CLog::Log(LOGDEBUG, "CBlurayDirectory::GetTitles - disc.inf found"); CRegExp pl(true); if (!pl.RegComp("(\\d+)")) { file.Close(); return userTitles; } uint8_t maxLines = 100; while ((maxLines > 0) && file.ReadString(buffer, 1024)) { maxLines--; if (StringUtils::StartsWithNoCase(buffer, "playlists")) { int pos = 0; while ((pos = pl.RegFind(buffer, static_cast<unsigned int>(pos))) >= 0) { std::string playlist = pl.GetMatch(0); uint32_t len = static_cast<uint32_t>(playlist.length()); if (len <= 5) { unsigned long int plNum = strtoul(playlist.c_str(), nullptr, 10); BLURAY_TITLE_INFO* t = bd_get_playlist_info(m_bd, static_cast<uint32_t>(plNum), 0); if (t) userTitles.emplace_back(t); } if (static_cast<int64_t>(pos) + static_cast<int64_t>(len) > INT_MAX) break; else pos += len; } } } file.Close(); } return userTitles; }
bool BDRingBuffer::SwitchPlaylist(uint32_t index) { if (!bdnav) return false; if (m_currentTitleInfo) bd_free_title_info(m_currentTitleInfo); m_currentTitleInfo = bd_get_playlist_info(bdnav, index); if (!m_currentTitleInfo) return false; return UpdateTitleInfo(index); }
BLURAY_TITLE_INFO* BDRingBuffer::GetPlaylistInfo(uint32_t index) { if (!bdnav) return NULL; QMutexLocker locker(&m_infoLock); if (m_cachedPlaylistInfo.contains(index)) return m_cachedPlaylistInfo.value(index); BLURAY_TITLE_INFO* result = bd_get_playlist_info(bdnav, index); if (result) { VERBOSE(VB_PLAYBACK, LOC + QString("Found playlist %1 info").arg(index)); m_cachedPlaylistInfo.insert(index,result); return result; } return NULL; }
JNIEXPORT jobject JNICALL Java_org_videolan_Libbluray_getPlaylistInfoN (JNIEnv * env, jclass cls, jlong np, jint playlist) { BLURAY *bd = (BLURAY*)(intptr_t)np; BLURAY_TITLE_INFO* ti; BD_DEBUG(DBG_JNI, "getPlaylistInfoN(%d)\n", (int)playlist); ti = bd_get_playlist_info(bd, playlist, 0); if (!ti) return NULL; jobject titleInfo = _make_playlist_info(env, ti); bd_free_title_info(ti); return titleInfo; }
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; }