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

FLV support #10756

Merged
merged 68 commits into from
Jun 30, 2023
Merged

FLV support #10756

merged 68 commits into from
Jun 30, 2023

Conversation

kmeisthax
Copy link
Member

@kmeisthax kmeisthax commented Apr 21, 2023

This PR adds FLV support. Notably, only video: the existing streaming audio APIs want to work with either SWF bitstreams or single contiguous blocks of MP3 data. That needs refactoring big enough to justify a separate PR.

FLV also, bizarrely, has functionality for calling ActionScript methods from the video stream. Yes, the onMetaData event is actually triggered by one of these script calls; and no I did not implement it yet. I still do need to parse this block in order to not violate the video backend's existing API prerequisites, though.

This can't be merged until ruffle-rs/h263-rs#50 is merged and this PR is updated to target the merged version. I rolled that PR into this one so it can be merged in one go.

@TheGhostboi64
Copy link

this is very cool! A defunct website I recreate mostly uses FLVs for the intros and others, so I can't wait to see it working! Nice!

@danielhjacobs
Copy link
Contributor

danielhjacobs commented Apr 21, 2023

Progresses http://labcenter.dnalc.org/labs/dnaextraction/dnaextraction_d.html (uses VP6A and MP3 codecs with external FLV files), which used to say:

  • ERROR core/src/tag_utils.rs:414 Error running definition tag: DefineVideoStream, got Couldn't read SWF
  • ERROR core/src/library.rs:200 Tried to instantiate non-registered character ID 439
  • ERROR core/src/display_object/movie_clip.rs:1611 Unable to instantiate display node id 439, reason being: Character id doesn't exist

It now says:

  • ERROR core/src/streams.rs:398 Decoding video frame [0-4] failed: Decoder error: InvalidData
  • WARN core/src/display_object/video.rs:565 Video has no decoded frame to render.

There is no functional difference between what used to happen on that site and what happens now though, unfortunately.

Progresses #10173 (uses H.264 codec with external MP4 files), number 2, which used to say:

  • ERROR core/src/avm2/events.rs:419 Error dispatching event EventObject(EventObject { type: "click", class: flash.events::MouseEvent, ptr: 0x1586748 }) to handler FunctionObject(FunctionObject { ptr: 0x1497430 }) : TypeError: Error #1009: Cannot access a property or method of a null object reference. (accessing field: isWaiting)

It now says:

  • WARN core/src/stub.rs:126 Encountered stub: AVM2 flash.net.NetConnection.connect()
  • WARN core/src/stub.rs:126 Encountered stub: AVM2 flash.net.NetStream.client setter
  • WARN core/src/stub.rs:126 Encountered stub: AVM2 flash.net.NetStream.bufferTime setter
  • WARN core/src/stub.rs:126 Encountered stub: AVM2 flash.net.NetStream.soundTransform setter
  • WARN core/src/stub.rs:126 Encountered stub: AVM2 flash.net.NetStream.soundTransform getter
  • WARN core/src/stub.rs:126 Encountered stub: AVM2 flash.net.NetStream.time getter
  • WARN core/src/display_object/video.rs:565 Video has no decoded frame to render.

There is no functional difference between what used to happen on that site and what happens now though, unfortunately.

Progresses #10175, number 2, which used to say:

  • ERROR core/src/display_object/movie_clip.rs:2135 Got "RustError("ArgumentError: Child not a valid display object")" when constructing AVM2 side of movie clip of type fl.video::FLVPlayback
  • ERROR core/src/display_object/movie_clip.rs:2135 Got "TypeError: Error #1010: A term is undefined and has no properties. (accessing field: TEXT_LAYOUT_FORMAT)

It now says:

  • core/src/display_object/movie_clip.rs:2135 Got "TypeError: Error #1010: A term is undefined and has no properties. (accessing field: TEXT_LAYOUT_FORMAT)

There is no functional difference between what used to happen on that site and what happens now though, unfortunately.

Progresses #10175, number 3 in the same way described for #10173, number 2.

@Lord-McSweeney
Copy link
Collaborator

Fixes #10705.

@waspennator
Copy link

waspennator commented Apr 21, 2023

Should progress the flv issue for #10149?

@Lord-McSweeney
Copy link
Collaborator

I think the reason there's no functional difference currently is because the FLV PR isn't yet merged into the h263-rs repo.

@danielhjacobs
Copy link
Contributor

But wasn't the cargo lock changed to point to kmeisthax's latest commit?

@kmeisthax
Copy link
Member Author

Daniel is correct, flv-rs is being pulled in by commit ID separate from the other h263-rs packages. Hence why this is still in draft. (or it would be if I hadn't accidentally clicked the regular save button and had a clue as to how to turn on draft mode for a non-draft PR)

@Lord-McSweeney
Copy link
Collaborator

Lord-McSweeney commented Apr 22, 2023

You can turn it into a real draft by clicking the "Still in progress? Convert to draft" text below Reviewers - Suggestions, which is on the top-right of the page in Github.

@kmeisthax kmeisthax marked this pull request as draft April 22, 2023 18:00
@kmeisthax
Copy link
Member Author

I love how that link is buried where you can't find it

@torokati44
Copy link
Member

FWIW you can also switch the "Open PR" button to open as a draft right away.

@kmeisthax kmeisthax force-pushed the netstream-flv branch 3 times, most recently from 1a4e411 to eb4de1b Compare April 23, 2023 00:28
.into())
.into();

ns.set_avm_object(activation.context.gc_context, this.into());
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I do not know if I like the cyclic reference between the Object and NetStream, but it might be fine, and alternatives, like a callback, might be overall worse.

movie: Arc<SwfMovie>,

/// The self bounds for this movie.
size: (i32, i32),
Copy link
Contributor

@iwannabethedev iwannabethedev May 12, 2023

Choose a reason for hiding this comment

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

Nit: Might this be better as (u32, 32)? Might be better as it currently is.

core/src/streams.rs Outdated Show resolved Hide resolved
FlvTagData::Audio(FlvAudioData { .. }) => {
tracing::warn!("Stub: Stream audio processing");
}
FlvTagData::Video(FlvVideoData { codec_id, data, .. }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The function is somewhat long. Would it be helpful (or worse) to maybe put parts of this function into their own functions that is called from here? Like, a function that might be called handle_flv_tag_data_video() for this match?

But, one problem with that is how it would interfere with the loop, in case there are return or break or continue statements and the like. The usage of a loop, together with a lot of code, feels a bit difficult to handle to me, though I could be wrong, both on this point and on possible alternatives on organizing the code being sufficiently better to change to one of them.

@iwannabethedev
Copy link
Contributor

iwannabethedev commented May 12, 2023

It is obvious that a lot of time and effort went into this PR. I know too little of Rust, Ruffle and video playing to really give good feedback on this, but I have tried to leave a few comments. The PR is also rather long, making it more difficult to review. Parts that I think would be good to review is the overall type design and interface between the different parts of the codebase, and maybe also a light review of parts of the implementation, though this is of course only an initial PR and many parts have not been implemented yet or are works in progress.

@kmeisthax What do you think? Are there any specific aspects and parts of the PR that you would like to have reviewed?

I have not really reviewed this, so it is still in need of reviewing.

@Lord-McSweeney
Copy link
Collaborator

https://www.nothingtodo.co.uk/view/3136/who-needs-a-glove.html logs "Video has no decoded frame to render" with this PR.

@Lord-McSweeney
Copy link
Collaborator

Since DisplayObjects use instance allocators now, this needs to define an instance allocator on Video.

@kmeisthax kmeisthax enabled auto-merge (rebase) June 29, 2023 23:42
@torokati44
Copy link
Member

I posted a different Screen V1 test FLV on Discord, which will hopefully be less sensitive to platform differences.

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.

10 participants