Skip to content

Commit

Permalink
fix: Fix SetTextureSize when using VideoSourceType.Texture (#885)
Browse files Browse the repository at this point in the history
* fix SetTextureSize when using VideoSourceType.Texture

* fix

* fix

* fix
  • Loading branch information
karasusan authored Feb 21, 2023
1 parent 0bebc23 commit b164082
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions com.unity.renderstreaming/Editor/VideoStreamSenderEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ private void HandleDataSourceField()
EditorGUILayout.EndFadeGroup();

if (EditorGUILayout.BeginFadeGroup(m_sourceFade[(int)VideoStreamSource.Texture].faded))
{
EditorGUILayout.PropertyField(m_texture);
EditorGUILayout.PropertyField(m_textureSize);
}
EditorGUILayout.EndFadeGroup();

if (EditorGUILayout.BeginFadeGroup(m_sourceFade[(int)VideoStreamSource.WebCamera].faded))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,6 @@ public void SetScaleResolutionDown(float scaleFactor)
/// <param name="size"></param>
public void SetTextureSize(Vector2Int size)
{
if (m_Source == VideoStreamSource.Texture)
throw new InvalidOperationException("Video source is set Texture.");
m_TextureSize = size;

if (!isPlaying)
Expand Down Expand Up @@ -581,7 +579,7 @@ public override WaitForCreateTrack CreateTrack()

GraphicsFormat format =
WebRTC.WebRTC.GetSupportedGraphicsFormat(SystemInfo.graphicsDeviceType);
if (m_texture.graphicsFormat == format)
if (m_texture.graphicsFormat == format && m_texture.width == width && m_texture.height == height)
{
instruction.Done(new VideoStreamTrack(m_texture));
return instruction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,8 @@ private void ChangeResolution(int index)
{
var resolution = resolutionOptions.Values.ElementAt(index);

if (videoStreamSender.source != VideoStreamSource.Texture)
{
videoStreamSender.SetTextureSize(resolution);
CalculateInputRegion();
}
videoStreamSender.SetTextureSize(resolution);
CalculateInputRegion();
}

private void Start()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public IEnumerator CreateTrack()
Assert.That(sender.sourceTexture, Is.Not.Null);
Assert.That(sender.width, Is.EqualTo(width));
Assert.That(sender.height, Is.EqualTo(height));
Assert.That(() => sender.width = 1280, Throws.Exception.TypeOf<InvalidOperationException>());
Assert.That(() => sender.height = 720, Throws.Exception.TypeOf<InvalidOperationException>());
Assert.That(() => sender.width = 1280, Throws.Nothing);
Assert.That(() => sender.height = 720, Throws.Nothing);
op = sender.CreateTrack();
yield return op;
track = op.Track;
Expand Down

0 comments on commit b164082

Please sign in to comment.