Skip to content

Commit

Permalink
Revert "add all my nasty debugging"
Browse files Browse the repository at this point in the history
This reverts commit 491651a.
  • Loading branch information
sshane committed May 24, 2024
1 parent 491651a commit 36d5394
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 51 deletions.
2 changes: 0 additions & 2 deletions src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,6 @@ export function checkRoutesData() {
let startTime = r.segment_start_times[0];
let endTime = r.segment_end_times[r.segment_end_times.length - 1];

// console.log('offset bullshit', startTime, Math.round(startTime), state.filter.start, Math.round(startTime) - state.filter.start)

// TODO: these will all be relative times soon
// fix segment boundary times for routes that have the wrong time at the start
if ((Math.abs(r.start_time_utc_millis - startTime) > 24 * 60 * 60 * 1000)
Expand Down
1 change: 0 additions & 1 deletion src/components/DriveMap/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class DriveMap extends Component {
const { offset } = this.props.currentRoute;

const pos = this.posAtOffset(currentOffset() - offset);
console.log('fds', currentOffset())
if (pos) {
markerSource.setData({
type: 'Point',
Expand Down
33 changes: 0 additions & 33 deletions src/components/DriveVideo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class DriveVideo extends Component {
}

componentDidMount() {
console.log('componentDidMount')
const { playSpeed } = this.props;
if (this.videoPlayer.current) {
this.videoPlayer.current.playbackRate = playSpeed || 1;
Expand All @@ -87,21 +86,6 @@ class DriveVideo extends Component {
}

componentDidUpdate(prevProps) {
console.log('componentDidUpdate')

// Compare props
if (prevProps.src !== this.props.src) {
console.log('Prop src changed from', prevProps.src, 'to', this.props.src);
}
if (prevProps.currentRoute !== this.props.currentRoute) {
console.log('Prop currentRoute changed from', prevProps.currentRoute, 'to', this.props.currentRoute);
}
if (prevProps.isBufferingVideo !== this.props.isBufferingVideo) {
console.log('Prop isBufferingVideo changed from', prevProps.isBufferingVideo, 'to', this.props.isBufferingVideo);
}

console.log("didUpdate currentRoute", this.props.currentRoute)

this.updateVideoSource(prevProps);
this.syncVideo();
}
Expand All @@ -114,11 +98,9 @@ class DriveVideo extends Component {
}

onVideoBuffering() {
console.log('onVideoBuffering')
const { dispatch, currentRoute } = this.props;
const videoPlayer = this.videoPlayer.current;
if (!videoPlayer || !currentRoute || !videoPlayer.getDuration()) {
console.log('buffering1')
dispatch(bufferVideo(true));
}

Expand All @@ -130,7 +112,6 @@ class DriveVideo extends Component {
const { hasLoaded } = getVideoState(videoPlayer);
const { readyState } = videoPlayer.getInternalPlayer();
if (!hasLoaded || readyState < 2) {
console.log('buffering2')
dispatch(bufferVideo(true));
}
}
Expand All @@ -139,9 +120,7 @@ class DriveVideo extends Component {
* @param {Error} e
*/
onHlsError(e) {
console.error('HLS error', e);
const { dispatch } = this.props;
console.log('buffering3')
dispatch(bufferVideo(true));

if (e.type === 'mediaError' && (e.details === 'bufferStalledError' || e.details === 'bufferNudgeOnStall')) {
Expand Down Expand Up @@ -185,7 +164,6 @@ class DriveVideo extends Component {
}

const { dispatch } = this.props;
console.log('buffering4')
dispatch(bufferVideo(true));

if (e.type === 'networkError') {
Expand All @@ -201,34 +179,28 @@ class DriveVideo extends Component {
}

onVideoResume() {
console.log("onVideoResume")
const { videoError } = this.state;
if (videoError) this.setState({ videoError: null });
}

updateVideoSource(prevProps) {
console.log("updateVideoSource")
let { src } = this.state;
const { currentRoute } = this.props;
console.log('currentRoute', currentRoute)
if (!currentRoute) {
if (src !== '') {
this.setState({ src: '', videoError: null });
}
return;
}

console.log('getting src!')
if (src === '' || !prevProps.currentRoute || prevProps.currentRoute?.fullname !== currentRoute.fullname) {
src = Video.getQcameraStreamUrl(currentRoute.fullname, currentRoute.share_exp, currentRoute.share_sig);
console.log('got src', src)
this.setState({ src, videoError: null });
this.syncVideo();
}
}

syncVideo() {
console.log('syncVideo')
const { dispatch, isBufferingVideo, currentRoute } = this.props;
if (!currentRoute) {
dispatch(updateSegments());
Expand Down Expand Up @@ -269,11 +241,9 @@ class DriveVideo extends Component {
const { hasLoaded, bufferRemaining } = getVideoState(videoPlayer);
const hasSufficientBuffer = bufferRemaining >= sufficientBuffer;
if (isBufferingVideo && hasSufficientBuffer && internalPlayer.readyState >= 2) {
console.log('buffering7')
dispatch(bufferVideo(false));
} else if (isBufferingVideo || !hasLoaded || internalPlayer.readyState < 2) {
if (!isBufferingVideo) {
console.log('buffering8')
dispatch(bufferVideo(true));
}
newPlaybackRate = 0;
Expand All @@ -298,7 +268,6 @@ class DriveVideo extends Component {
}

currentVideoTime(offset = currentOffset()) {
console.log('currentVideoTime', offset)
const { currentRoute } = this.props;
if (!currentRoute) {
return 0;
Expand All @@ -310,15 +279,13 @@ class DriveVideo extends Component {
}

offset /= 1000;
console.log('currentVideoTime2', offset)

return Math.max(0, offset);
}

render() {
const { desiredPlaySpeed, isBufferingVideo, currentRoute } = this.props;
const { src, videoError } = this.state;
console.log('src', src, videoError)
return (
<div className="min-h-[200px] relative max-w-[964px] m-[0_auto] aspect-[1.593]">
<VideoOverlay loading={isBufferingVideo} error={videoError} />
Expand Down
1 change: 0 additions & 1 deletion src/components/Timeline/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ class Timeline extends Component {
}
raf(this.getOffset);
let offset = currentOffset();
console.log('getOffset', offset)
if (this.seekIndex) {
offset = this.seekIndex;
}
Expand Down
16 changes: 3 additions & 13 deletions src/timeline/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,22 @@ export function currentOffset(state = null) {
state = store.getState();
}

console.log('in currentOffset', state.offset)
console.log('is buffering', state.isBufferingVideo)

/** @type {number} */
let offset;
if (state.offset === null && state.loop?.startTime) {
console.log('null offset')
offset = state.loop.startTime - state.filter.start;
} else {
console.log('not null offset', state.offset)
const playSpeed = state.isBufferingVideo ? 0 : state.desiredPlaySpeed;
offset = state.offset + ((Date.now() - state.startTime) * playSpeed);
console.log('new offset', offset)
}

if (offset !== null && state.loop?.startTime) {
// respect the loop
const loopOffset = state.loop.startTime - state.filter.start;
if (offset < loopOffset) {
offset = loopOffset;
console.log('loop offset', offset)
} else if (offset > loopOffset + state.loop.duration) {
offset = ((offset - loopOffset) % state.loop.duration) + loopOffset;
console.log('loop offset2', offset)
}
}

Expand All @@ -49,23 +41,21 @@ export function currentOffset(state = null) {
* @returns {*|null}
*/
export function getCurrentRoute(state, offset) {
console.log('state.routes', state.routes)
if (!state.routes) return null;

offset = offset || currentOffset(state);
console.log('offset123', offset)
if (offset === null) return null;


// loop through state.routes:
for (let i = 0; i < state.routes.length; i++) {
const route = state.routes[i];
// console.log('route off', route.offset)
// console.log('route', offset >= (route.offset - 0) && offset <= route.offset + route.duration + 0)
console.log('route off', route.offset)
console.log('route', offset >= (route.offset - 0) && offset <= route.offset + route.duration + 0)
}


// Add 1s of tolerance as route start/end times are only second precision while segment times are millisecond
return state.routes
.find((route) => offset >= route.offset - 0 && offset <= route.offset + route.duration + 0);
.find((route) => offset >= route.offset - 1000 && offset <= route.offset + route.duration + 1000);
}
1 change: 0 additions & 1 deletion src/timeline/segments.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export function reducer(_state, action) {
}

const currentRoute = getCurrentRoute(state);
console.log("updating segments", currentRoute)
state.currentRoute = currentRoute ? { ...currentRoute } : null;

return state;
Expand Down

0 comments on commit 36d5394

Please sign in to comment.