int eMPEGStreamInformation::load(const char *filename) { //eDebug("[eMPEGStreamInformation] {%d} load(%s)", gettid(), filename); close(); std::string s_filename(filename); m_structure_read_fd = ::open((s_filename + ".sc").c_str(), O_RDONLY | O_CLOEXEC); m_access_points.clear(); m_pts_to_offset.clear(); m_timestamp_deltas.clear(); CFile f((s_filename + ".ap").c_str(), "rb"); if (!f) return -1; while (1) { unsigned long long d[2]; if (fread(d, sizeof(d), 1, f) < 1) break; d[0] = be64toh(d[0]); d[1] = be64toh(d[1]); m_access_points[d[0]] = d[1]; m_pts_to_offset.insert(std::pair<pts_t,off_t>(d[1], d[0])); } /* assume the accesspoints are in streamtime, if they start with a 0 timestamp */ m_streamtime_accesspoints = (!m_access_points.empty() && m_access_points.begin()->second == 0); fixupDiscontinuties(); return 0; }
int eMPEGStreamInformation::load(const char *filename) { m_filename = filename; if (m_structure_read) fclose(m_structure_read); m_structure_read = fopen((std::string(m_filename) + ".sc").c_str(), "rb"); FILE *f = fopen((std::string(m_filename) + ".ap").c_str(), "rb"); if (!f) return -1; m_access_points.clear(); m_pts_to_offset.clear(); while (1) { unsigned long long d[2]; if (fread(d, sizeof(d), 1, f) < 1) break; #if BYTE_ORDER == LITTLE_ENDIAN d[0] = bswap_64(d[0]); d[1] = bswap_64(d[1]); #endif m_access_points[d[0]] = d[1]; m_pts_to_offset.insert(std::pair<pts_t,off_t>(d[1], d[0])); } fclose(f); fixupDiscontinuties(); return 0; }