Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate duration correctly when pipeline paused #559

Merged

Conversation

paulgration
Copy link
Contributor

I came across this when wanting to get the current duration of a recording from within a plugin..

The pausetype configuration determines which pause method of the Recorder is used when pausing a recording (the two methods are pause() or pause_recording()).
The calculation to determine the current duration of the pipeline takes into account the __pause_timestamp property of the Recorder, however __pause_timestamp is only set in pause_recording() not in pause().
As a result, when a recording is paused and the pausetype is pipeline, any calls to Recorder.get_recording_start_time() return the incorrect duration of 1439:59. This isn't reflected in the UI because the text for the Elapsed Time only updates when in the recording state, so while paused it displays a stale value.

Using the following snippet as a plugin works for testing:

import datetime
from galicaster.core import context
from galicaster.utils import readable

conf = context.get_conf()
dispatcher = context.get_dispatcher()
recorder = context.get_recorder()

def init():
    dispatcher.connect('timer-short', on_timer_short)

def on_timer_short(source):
    msec = datetime.timedelta(microseconds=(round(recorder.get_recorded_time()/1000.0,-6)))
    print 'Elapsed time:', readable.long_time(msec)

It may be worth refactoring the RecorderService and Recorder at some point so that there is only one Recorder.pause() and Recorder.resume() each with an argument specifying the pausetype, for now this PR is all that is required to get the duration calculated correctly.

@Alfro Alfro merged commit 0670668 into teltek:2.0.x Nov 16, 2017
@Alfro
Copy link
Contributor

Alfro commented Nov 16, 2017

Thank you!
I'll keep this in mind as well.

@paulgration paulgration deleted the fix_duration_pipeline_paused branch November 20, 2017 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants