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

Hardcoded header in IVFWriter #484

Merged
merged 1 commit into from
Mar 7, 2019
Merged

Hardcoded header in IVFWriter #484

merged 1 commit into from
Mar 7, 2019

Conversation

Antonito
Copy link
Member

@Antonito Antonito commented Mar 6, 2019

Relates to #471

The framecount of the IVF header is now updated when we call the Close method.
I'm considering passing the width and height fields as parameters to New() method, and keeping a constan 30 framerate. Any thoughts on this?

@backkem backkem added the review label Mar 6, 2019
@coveralls
Copy link

coveralls commented Mar 7, 2019

Pull Request Test Coverage Report for Build 2415

  • 2 of 10 (20.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.03%) to 80.531%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/media/ivfwriter/ivfwriter.go 2 10 20.0%
Files with Coverage Reduction New Missed Lines %
pkg/media/ivfwriter/ivfwriter.go 1 67.44%
Totals Coverage Status
Change from base Build 2409: 0.03%
Covered Lines: 4095
Relevant Lines: 5085

💛 - Coveralls

@Sean-Der
Copy link
Member

Sean-Der commented Mar 7, 2019

Nice work @Antonito

I think this makes the example more complicated that it needs to be (IMO) feel free to push back.

Can you try watch the webrtc.ICEConnectionState instead? I think the code might read cleaner if when we get failed we .Close() both files. https://github.com/pions/webrtc/blob/master/examples/save-to-disk/main.go#L100

We can then tell users 'refresh the demo page and when the client times out it will exit' also the code will be easier to follow (less LOC and no channels etc..)

@Sean-Der
Copy link
Member

Sean-Der commented Mar 7, 2019

Also the width and height I don't think will be possible to pass in :(

WebRTC allows clients to change resolution on the fly (to adjust with available bandwidth) so we don't have anything we can do.

Copy link
Member Author

@Antonito Antonito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @Antonito

I think this makes the example more complicated that it needs to be (IMO) feel free to push back.

Can you try watch the webrtc.ICEConnectionState instead? I think the code might read cleaner if when we get failed we .Close() both files. https://github.com/pions/webrtc/blob/master/examples/save-to-disk/main.go#L100

We can then tell users 'refresh the demo page and when the client times out it will exit' also the code will be easier to follow (less LOC and no channels etc..)

Yeah, I feel the example is being a bit over-complicated. I like your implementation better, it's simpler!

@@ -64,6 +64,7 @@ func main() {
// Set a handler for when a new remote track starts, this handler saves buffers to disk as
// an ivf file, since we could have multiple video tracks we provide a counter.
// In your application this is where you would handle/process video
mediaRecorder := []media.Writer{nil, nil}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put a sync.Mutex around this. Just need to lock since ICE+OnTrack fire in threads

@@ -98,6 +101,21 @@ func main() {
// This will notify you when the peer has connected/disconnected
peerConnection.OnICEConnectionStateChange(func(connectionState webrtc.ICEConnectionState) {
fmt.Printf("Connection State has changed %s \n", connectionState.String())

if connectionState == webrtc.ICEConnectionStateConnected {
fmt.Println("Ctrl+C the client to stop the demo")
Copy link
Member

@Sean-Der Sean-Der Mar 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means .Close() will never get called right? If you want to support Ctrl-C that would be really cool also!

I would put a note in the README the created ivf and opus files will exist, but headers will only have temporary values and may not play properly if they don't end the example properly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this needs to be more explicit then. By client, I meant the JS fiddle thing for example. If you "ctrl+c" it (or close the tab), the Go program will detect the connection is closed, will update the headers, close the files and terminate.

I thought about supporting ctrl+c in the Go example, but also wanted to keep the example simple. I can add it if you think it's relevant!

@Sean-Der
Copy link
Member

Sean-Der commented Mar 7, 2019

Looks much better! This is great, just a few nits/questions but we could merge now if you don't want to support Ctrl-C !

Copy link
Member

@Sean-Der Sean-Der left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work

- Added timeout to save-to-disk example
- Writing number of IVF frames when closing the file
- Fixed typos

Relates to #471
@Antonito Antonito merged commit 6a68ca0 into master Mar 7, 2019
@Antonito Antonito deleted the issue-471 branch March 7, 2019 22:49
@backkem backkem removed the review label Mar 7, 2019
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.

None yet

4 participants