logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
stigaard  
#1 Posted : Tuesday, January 7, 2020 7:32:07 PM(UTC)
stigaard

Rank: Advanced Member

Groups: Registered
Joined: 5/20/2015(UTC)
Posts: 493
Man
Denmark
Location: Copenhagen, Denmark

Thanks: 389 times
Was thanked: 100 time(s) in 79 post(s)
Hi vMix,

I am reporting an issue using the TCP API. I am currently implementing a NodeJS package to easily interact with the TCP API. However, I am experiencing inconsistencies in the returned XML message, namely that on specific cases, the returned XML data length is not correctly returned from the vMix instance. I have tried different scenarios, and I think to have isolated it to be only an issue regarding non-ascii characters (e.g. emojis, chineese letters, or speciel characters such as danish).

The XML message is returned such as:

Code:
XML 1727
<vmix>(... CONTENT ...)</vmix>


And it seems that the data length - in this case 1727, is not correct when having e.g. 13 "å" characters, e.g. as content in a title input field. The data in this case is 1726, and the message returned states that 1727 bytes are needed.
If 12 å character is used, it works fine - message is 1711 bytes, and message is:

Code:
XML 1711
<vmix>(... CONTENT ...)</vmix>


I noticed here that there is "a jump" on this specific length also. It normally jumps just 1 byte of data, where on this case, it jumps 15 bytes, somehow.

I have tried to illustrate the issue in these short video:
http://stigaard.info/vMix/vMix%20TCP%20API%20bug.mp4 (danish letters)
http://stigaard.info/vMix/vMix%20TCP%20API%20bug%20-%20Chineese.mp4 (Chineese letters)
On the left you see the TCP client connected to the vMix instance via TCP, and upon connection established, a message is sent 'XML'. Then is retrieved the XML data, which is then attempted to be parsed. On the right you see the vMix instance where the title is changed using the title editor.

I hope you can provide some info on where the root to the issue lies.

Best regards

Jens Stigaard
admin  
#2 Posted : Tuesday, January 7, 2020 8:27:28 PM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 1/13/2010(UTC)
Posts: 5,205
Man
Location: Gold Coast, Australia

Was thanked: 4283 time(s) in 1519 post(s)
Hi Jens,

This is correct as the number returned represents the number of bytes, not the number of characters.
As the output is UTF-8 encoded, characters in the ASCII set will take up one byte, while other
characters such as Chinese can take up 4 bytes.

So take the data length and copy in binary as a byte array. Then convert this to a string.
The string length will be in characters, while the byte array length will be in bytes.

Hope this helps.

Regards,

Martin
vMix
stigaard  
#3 Posted : Tuesday, January 7, 2020 8:31:54 PM(UTC)
stigaard

Rank: Advanced Member

Groups: Registered
Joined: 5/20/2015(UTC)
Posts: 493
Man
Denmark
Location: Copenhagen, Denmark

Thanks: 389 times
Was thanked: 100 time(s) in 79 post(s)
Originally Posted by: admin Go to Quoted Post
Hi Jens,

This is correct as the number returned represents the number of bytes, not the number of characters.
As the output is UTF-8 encoded, characters in the ASCII set will take up one byte, while other
characters such as Chinese can take up 4 bytes.

So take the data length and copy in binary as a byte array. Then convert this to a string.
The string length will be in characters, while the byte array length will be in bytes.



I also talk byte lengths, and not string lengths. However, it still doesn't match.
admin  
#4 Posted : Tuesday, January 7, 2020 8:44:41 PM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 1/13/2010(UTC)
Posts: 5,205
Man
Location: Gold Coast, Australia

Was thanked: 4283 time(s) in 1519 post(s)
If I create a blank preset with the title 0 gt template and set the headline text to 12 å,
the result is as follows:

XML 1450\r\n
**1450 bytes of XML including ending \r\n**

If i change this to 13 å the result is:

XML 1452\r\n
**1452 bytes of XML including ending \r\n**

So that all seems as expected. In vMix the TCP API code sends the length based on the exact byte buffer
it sends immediately after the \r\n, so it can't be incorrect.

I suspect the scripting language you are using is mangling the byte data somehow and/or converting it automatically
to ASCII instead of UTF-8 or something like that.

Regards,

Martin
vMix
admin  
#5 Posted : Tuesday, January 7, 2020 8:47:41 PM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 1/13/2010(UTC)
Posts: 5,205
Man
Location: Gold Coast, Australia

Was thanked: 4283 time(s) in 1519 post(s)
One other possibility is that you might need to set the TCP connection to blocking so it waits for all the requested data before returning.
If it is returning less data it might just mean it is an async connection and returning whatever it has received.
stigaard  
#6 Posted : Tuesday, January 7, 2020 8:49:42 PM(UTC)
stigaard

Rank: Advanced Member

Groups: Registered
Joined: 5/20/2015(UTC)
Posts: 493
Man
Denmark
Location: Copenhagen, Denmark

Thanks: 389 times
Was thanked: 100 time(s) in 79 post(s)
Hi Martin,

Thanks a lot - my bad - it were a brain fart in my code, not comparing correctly.

Sorry for the inconvenience.
admin  
#7 Posted : Tuesday, January 7, 2020 8:56:24 PM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 1/13/2010(UTC)
Posts: 5,205
Man
Location: Gold Coast, Australia

Was thanked: 4283 time(s) in 1519 post(s)
No problem, glad you worked it out!
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.