Skip to content

Commit b164082

Browse files
authored
fix: Fix SetTextureSize when using VideoSourceType.Texture (#885)
* fix SetTextureSize when using VideoSourceType.Texture * fix * fix * fix
1 parent 0bebc23 commit b164082

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

com.unity.renderstreaming/Editor/VideoStreamSenderEditor.cs

+3
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ private void HandleDataSourceField()
120120
EditorGUILayout.EndFadeGroup();
121121

122122
if (EditorGUILayout.BeginFadeGroup(m_sourceFade[(int)VideoStreamSource.Texture].faded))
123+
{
123124
EditorGUILayout.PropertyField(m_texture);
125+
EditorGUILayout.PropertyField(m_textureSize);
126+
}
124127
EditorGUILayout.EndFadeGroup();
125128

126129
if (EditorGUILayout.BeginFadeGroup(m_sourceFade[(int)VideoStreamSource.WebCamera].faded))

com.unity.renderstreaming/Runtime/Scripts/VideoStreamSender.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,6 @@ public void SetScaleResolutionDown(float scaleFactor)
423423
/// <param name="size"></param>
424424
public void SetTextureSize(Vector2Int size)
425425
{
426-
if (m_Source == VideoStreamSource.Texture)
427-
throw new InvalidOperationException("Video source is set Texture.");
428426
m_TextureSize = size;
429427

430428
if (!isPlaying)
@@ -581,7 +579,7 @@ public override WaitForCreateTrack CreateTrack()
581579

582580
GraphicsFormat format =
583581
WebRTC.WebRTC.GetSupportedGraphicsFormat(SystemInfo.graphicsDeviceType);
584-
if (m_texture.graphicsFormat == format)
582+
if (m_texture.graphicsFormat == format && m_texture.width == width && m_texture.height == height)
585583
{
586584
instruction.Done(new VideoStreamTrack(m_texture));
587585
return instruction;

com.unity.renderstreaming/Samples~/Example/Broadcast/BroadcastSample.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,8 @@ private void ChangeResolution(int index)
173173
{
174174
var resolution = resolutionOptions.Values.ElementAt(index);
175175

176-
if (videoStreamSender.source != VideoStreamSource.Texture)
177-
{
178-
videoStreamSender.SetTextureSize(resolution);
179-
CalculateInputRegion();
180-
}
176+
videoStreamSender.SetTextureSize(resolution);
177+
CalculateInputRegion();
181178
}
182179

183180
private void Start()

com.unity.renderstreaming/Tests/Runtime/StreamingComponentTest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public IEnumerator CreateTrack()
113113
Assert.That(sender.sourceTexture, Is.Not.Null);
114114
Assert.That(sender.width, Is.EqualTo(width));
115115
Assert.That(sender.height, Is.EqualTo(height));
116-
Assert.That(() => sender.width = 1280, Throws.Exception.TypeOf<InvalidOperationException>());
117-
Assert.That(() => sender.height = 720, Throws.Exception.TypeOf<InvalidOperationException>());
116+
Assert.That(() => sender.width = 1280, Throws.Nothing);
117+
Assert.That(() => sender.height = 720, Throws.Nothing);
118118
op = sender.CreateTrack();
119119
yield return op;
120120
track = op.Track;

0 commit comments

Comments
 (0)