Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
738 stars 185 forks source link

[BUG]: Bug or feature? #972

Closed MaximKurbanov closed 9 months ago

MaximKurbanov commented 9 months ago

Package version

3.0.0-pre.6

Environment

* OS: All
* Unity version: 2021+

Steps To Reproduce

By default, when sending and receiving video, the picture flips vertically.

Sender: //Flip vertically Graphics.Blit(sourceTexture_, destTexture_, s_verticalScale, s_verticalOffset); Receiver: and receiver flip back m_renderer = new UnityVideoRenderer(this, needFlip: true);

It is not possible for the plugin user to change the auto flip of the receiver

/// <summary>
/// Video Receiver
/// </summary>
/// <param name="ptr"></param>
internal VideoStreamTrack(IntPtr ptr)
    : base(CreateVideoTrack(ptr))
{
    if (!s_tracks.TryAdd(self, new WeakReference<VideoStreamTrack>(this)))
        throw new InvalidOperationException();

    m_dataptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VideoStreamTrackData)));
    Marshal.StructureToPtr(m_data, m_dataptr, false);

    m_renderer = new UnityVideoRenderer(this, true); <---
}

Current Behavior

No response

Expected Behavior

No response

Anything else?

No response

karasusan commented 9 months ago

@MaximKurbanov

VideoStreamTrack provides a constructor with a needFlip argument. Can you try this?

public VideoStreamTrack(Texture texture, bool needFlip = true)
MaximKurbanov commented 9 months ago

@karasusan This constructor for sender!

MaximKurbanov commented 9 months ago

Fixed #971