[vlc-devel] [PATCH] rd/bonjour: Use Chromecast name and model from TXT record

Marvin Scholz epirat07 at gmail.com
Tue Jul 18 20:37:26 CEST 2017


Please ignore this patch, it was included by accident.


On 18 Jul 2017, at 20:30, Marvin Scholz wrote:

> Extract the Chromecast name and model from the TXT records ("md", 
> "fn")
> and use them as name, if available, to make it easier to identify the
> Chromecast.
> ---
>  modules/services_discovery/bonjour.m | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/modules/services_discovery/bonjour.m 
> b/modules/services_discovery/bonjour.m
> index 03552aec54..6f7261e5d6 100644
> --- a/modules/services_discovery/bonjour.m
> +++ b/modules/services_discovery/bonjour.m
> @@ -301,9 +301,19 @@ - (void)addResolvedRendererItem:(NSNetService 
> *)netService withProtocol:(NSStrin
>
>      NSString *uri = [NSString stringWithFormat:@"%@://%@:%ld", 
> protocol, netService.hostName, netService.port];
>      NSDictionary *txtDict = [NSNetService 
> dictionaryFromTXTRecordData:[netService TXTRecordData]];
> -
> +    NSString *displayName = netService.name;
> +
> +    if ([netService.type isEqualToString:@"_googlecast._tcp."]) {
> +        NSData *modelData = [txtDict objectForKey:@"md"];
> +        NSData *nameData = [txtDict objectForKey:@"fn"];
> +        if (modelData && nameData) {
> +            NSString *model = [[NSString alloc] 
> initWithData:modelData encoding:NSUTF8StringEncoding];
> +            NSString *name = [[NSString alloc] initWithData:nameData 
> encoding:NSUTF8StringEncoding];
> +            displayName = [NSString stringWithFormat:@"%@ (%@)", 
> name, model];
> +        }
> +    }
>      // TODO: Detect rendered capabilities and adapt to work with not 
> just chromecast
> -    vlc_renderer_item_t *p_renderer_item = vlc_renderer_item_new( 
> "chromecast", [netService.name UTF8String],
> +    vlc_renderer_item_t *p_renderer_item = vlc_renderer_item_new( 
> "chromecast", [displayName UTF8String],
>                                                                   [uri 
> UTF8String], NULL, "cc_demux",
>                                                                   "", 
> VLC_RENDERER_CAN_VIDEO );
>      if (p_renderer_item != NULL) {
> -- 
> 2.11.0 (Apple Git-81)


More information about the vlc-devel mailing list