Minidlna
http://www.dlna.org/consumer-home
minidlna에 대한 설명에 앞서서 DLNA에 대해서 설명한다.
DLNA(Digital Living Network Alliance)는 정확히는 소니를 필두로한 Home Media네트워크 목적의 비영리 단체이자 표준이다. DLNA라는 새로운 프로토콜은 사용한것이 아니다. 기존의 UPnP를 이용하면서, 몇가지 새로운것을 첨부한것에 불과하다. UPnP에 대해서 처음 듣는 사람들을 위해서 간단히 소개하면, 브로드캐스팅이 유효한 범위의 네트워크에서 자동으로 장치를 찾고 원격조종이 가능한 프로토콜이다.
국내에는 대형 TV제조사들(삼성,LG)의 제품에서 DLNA를 지원한다.
DLNA 구성 디바이스[편집]
<SyntaxHighlight lang="C"> DMS : 미디어를 제공하는 서버이다. minidlna가 여기 해당된다. DMR : 미디어를 재생하는 기능만 있는 장비이다. 미디어서버를 찾는 기능은 없다 DMC : DLNA장비를 제어하는 컨트롤러. DMS,DMC,DMR,DMP등을 원격조종한다. DMP : 간단히 DMR+DMC이다.
</SyntaxHighlight> minidlna는 DMS에 해당되는 데몬이다.
기본설치와 설정[편집]
apt-get 명령으로 곧바로 실행이 가능하다. 먼저 설치부터 하자.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo apt-get install minidlna|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo apt-get install minidlna}}}}
다음으로 익숙하게 conf파일을 수정해야한다.
핵심은 포트번호인 port,공유할 동영상 미디어 디렉토리 media_dir,미디어의 정보를 담은 sqlite 디렉터리 db_dir
가 핵심이다. ubuntu를 사용하는 경우 /etc 폴더 하위에 minidlna.conf 파일이 존재한다.
<SyntaxHighlight lang="bash"> minidlna.conf </SyntaxHighlight> <SyntaxHighlight lang="bash">
- port for HTTP (descriptions, SOAP, media transfer) traffic
port=8200
- network interfaces to serve, comma delimited
- network_interface=eth0
- specify the user account name or uid to run as
- user=jmaggard
- set this to the directory you want scanned.
- * if you want multiple directories, you can have multiple media_dir= lines
- * if you want to restrict a media_dir to specific content types, you
- can prepend the types, followed by a comma, to the directory:
- + "A" for audio (eg. media_dir=A,/home/jmaggard/Music)
- + "V" for video (eg. media_dir=V,/home/jmaggard/Videos)
- + "P" for images (eg. media_dir=P,/home/jmaggard/Pictures)
- + "PV" for pictures and video (eg. media_dir=AV,/home/jmaggard/digital_camera)
- media_dir=/opt
media_dir=V,/home/user/video
- set this if you want to customize the name that shows up on your clients
- friendly_name=My DLNA Server
- set this if you would like to specify the directory where you want MiniDLNA to store its database and album art cache
- db_dir=/var/cache/minidlna
db_dir=/home/user/code/minidlna-1.1.2/minidlna_db
- set this if you would like to specify the directory where you want MiniDLNA to store its log file
- log_dir=/var/log
- set this to change the verbosity of the information that is logged
- each section can use a different level: off, fatal, error, warn, info, or debug
- log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn
- this should be a list of file names to check for when searching for album art
- note: names should be delimited with a forward slash ("/")
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
- set this to no to disable inotify monitoring to automatically discover new files
- note: the default is yes
inotify=yes
- set this to yes to enable support for streaming .jpg and .mp3 files to a TiVo supporting HMO
enable_tivo=no
- set this to strictly adhere to DLNA standards.
- * This will allow server-side downscaling of very large JPEG images,
- which may hurt JPEG serving performance on (at least) Sony DLNA products.
strict_dlna=no
- default presentation url is http address on port 80
- presentation_url=http://www.mylan/index.php
- notify interval in seconds. default is 895 seconds.
notify_interval=900
- serial and model number the daemon will report to clients
- in its XML description
serial=12345678 model_number=1
- specify the path to the MiniSSDPd socket
- minissdpdsocket=/var/run/minissdpd.sock
- use different container as root of the tree
- possible values:
- + "." - use standard container (this is the default)
- + "B" - "Browse Directory"
- + "M" - "Music"
- + "V" - "Video"
- + "P" - "Pictures"
- if you specify "B" and client device is audio-only then "Music/Folders" will be used as root
- root_container=.
- always force SortCriteria to this value, regardless of the SortCriteria passed by the client
- force_sort_criteria=+upnp:class,+upnp:originalTrackNumber,+dc:title
- maximum number of simultaneous connections
- note: many clients open several simultaneous connections while streaming
- max_connections=50
</SyntaxHighlight>
이제 데이터베이스를 갱신하자, 새로운 파일을 추가할때마다 필요한 작업이다.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo minidlnad -R|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo minidlnad -R}}}}
다음으로 서비스를 실행한다면, 결과물을 확인할수있다. restart를 사용하는 이유는 apt로 설치를 한다면 설치가 끝나자마자 실행되기때문에
restart를 이용하여 다시 실행하는것이다.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo service minidlna restart|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo service minidlna restart}}}}
smi 자막지원 추가[편집]
DLNA의 치명적인 단점중에 하나가 smi자막지원이 기본이 아니라는점이다. 그렇지만, 해당되는 minidlna의 소스를 수정함으로서 smi지원이 가능하게 할수있다. 당연하겠지만, 개발자용 패키지와 소스코드가 필요하다. 기준이되는 버젼은 1.13이다.
라이브러리 먼저 설치하자.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo apt-get install debhelper libavformat-dev libavutil-dev libavcodec-dev libflac-dev libvorbis-dev libid3tag0-dev libexif-dev libjpeg-dev libsqlite3-dev libogg-dev|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo apt-get install debhelper libavformat-dev libavutil-dev libavcodec-dev libflac-dev libvorbis-dev libid3tag0-dev libexif-dev libjpeg-dev libsqlite3-dev libogg-dev}}}}
다음으로 아래의 url로 접속하여 소스코드를 다운받고 압축을 해체한다.
<SyntaxHighlight lang="bash">
http://sourceforge.net/projects/minidlna/
</SyntaxHighlight>
압축이 해체된 디렉토리의 metadata.c의 check_for_captions 함수를 편집하는것이 핵심이다.
<SyntaxHighlight lang="bash"> metadata.c </SyntaxHighlight> <SyntaxHighlight lang="C"> void check_for_captions(const char *path, int64_t detailID) {
char *file = malloc(MAXPATHLEN); char *id = NULL;
sprintf(file, "%s", path); strip_ext(file);
/* If we weren't given a detail ID, look for one. */ if( !detailID ) { id = sql_get_text_field(db, "SELECT ID from DETAILS where (PATH > '%q.' and PATH <= '%q.z')" " and MIME glob 'video/*' limit 1", file, file); if( id ) { //DPRINTF(E_MAXDEBUG, L_METADATA, "New file %s looks like a caption file.\n", path); detailID = strtoll(id, NULL, 10); } else { //DPRINTF(E_MAXDEBUG, L_METADATA, "No file found for caption %s.\n", path); goto no_source_video; } }
strcat(file, ".srt"); if( access(file, R_OK) == 0 ) { sql_exec(db, "INSERT into CAPTIONS" " (ID, PATH) " "VALUES" " (%lld, %Q)", detailID, file); } else { strip_ext(file); strcat(file, ".smi"); if( access(file, R_OK) == 0 ) { sql_exec(db, "INSERT into CAPTIONS" " (ID, PATH) " "VALUES" " (%lld, %Q)", detailID, file); } }
no_source_video:
if( id ) sqlite3_free(id); free(file);
} </SyntaxHighlight>
이제 컴파일을 실행하자.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ ./configure|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} ./configure}}}}
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ make|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} make}}}}
기존의 설치된 실행파일을 중단시키고, 이전과 같이 설정파일을 편집한뒤 실행하자.
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo minidlnad -R -f ./minidlna.conf|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo minidlnad -R -f ./minidlna.conf}}}}
{{#ifeq: msg|user|~|{{#ifeq: misc|user|~ sudo minidlnad -f ./minidlna.conf|{{#ifeq: root|user|ubuntu-korea|{{#ifeq: user|user|user@ubuntu-korea|(undefined)}}}} ~ {{#ifeq: root|user|#|{{#ifeq: user|user|$|$}}}} sudo minidlnad -f ./minidlna.conf}}}}