[ios] AirPlay 디바이스 디스커버리

AirPlay는 Apple의 무선 스트리밍 기술로, iOS 기기로 오디오, 비디오 및 사진을 다른 AirPlay 호환 장치로 전송할 수 있습니다.

iOS 애플리케이션을 개발하는 경우, AirPlay 디바이스를 자동으로 발견하여 연결해야 할 수도 있습니다. 이를 위해서는 Apple의 Bonjour 서비스 및 DNS 서비스를 사용하여 네트워크에서 사용 가능한 AirPlay 디바이스를 찾아야 합니다.

Bonjour 서비스 사용

Bonjour는 네트워크 상에서 서비스를 발견하고 구성하는 기술로, iOS에서 AirPlay 디바이스를 찾는 데 사용됩니다.

아래의 예제는 Bonjour를 통해 AirPlay 디바이스를 찾는 Objective-C 코드입니다.

#import <Foundation/Foundation.h>
#import <dns_sd.h>

// Bonjour 브라우저 초기화
DNSServiceRef serviceRef;
DNSServiceBrowse(&serviceRef, 0, 0, "_airplay._tcp", NULL, browseCallback, NULL);

위 코드에서 DNSServiceBrowse 함수는 “_airplay._tcp”로 등록된 Bonjour 서비스를 찾기 위해 사용됩니다.

DNS 서비스 사용

DNS 서비스를 사용하여 AirPlay 디바이스의 IP 주소를 찾을 수도 있습니다. 아래의 Objective-C 코드는 DNS를 통해 AirPlay 디바이스를 찾는 방법을 보여줍니다.

#import <Foundation/Foundation.h>
#include <arpa/inet.h>
#include <netdb.h>

struct hostent *host = gethostbyname("airplaydevice.local");
char *ip = inet_ntoa(*((struct in_addr *)host->h_addr_list[0]));

위 코드에서 airplaydevice.local은 실제 AirPlay 디바이스의 이름으로 변경되어야 합니다.

AirPlay 디바이스 디스커버리에 대한 자세한 내용은 Apple의 Bonjour OverviewDNS Service Discovery 문서를 참조하십시오.

간단하게 요약하자면, iOS 애플리케이션에서 AirPlay 디바이스를 자동으로 찾기 위해서는 Bonjour 및 DNS 서비스를 사용하여 네트워크 상의 AirPlay 디바이스를 발견해야 합니다.