comparison libdlna-0.2.3/src/image_jpeg.c @ 129:4f6d9621ee00

add multi session streaming & add depending librarys. - libupnp-1.6.6 - libdlna-0.2.3
author Naoya OYAMA <naoya.oyama@gmail.com>
date Sun, 10 Oct 2010 15:33:18 +0900
parents
children
comparison
equal deleted inserted replaced
128:3a7d8d2f0585 129:4f6d9621ee00
1 /*
2 * libdlna: reference DLNA standards implementation.
3 * Copyright (C) 2007 Benjamin Zores <ben@geexbox.org>
4 *
5 * This file is part of libdlna.
6 *
7 * libdlna is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * libdlna is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with libdlna; if not, write to the Free Software
19 * Foundation, Inc, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 #include <stdlib.h>
23 #include <string.h>
24
25 #include "dlna_internals.h"
26 #include "profiles.h"
27
28 /* Profile for image media class content of small resolution */
29 static dlna_profile_t jpeg_sm = {
30 .id = "JPEG_SM",
31 .mime = MIME_IMAGE_JPEG,
32 .label = LABEL_IMAGE_PICTURE
33 };
34
35 /* Profile for image media class content of medium resolution */
36 static dlna_profile_t jpeg_med = {
37 .id = "JPEG_MED",
38 .mime = MIME_IMAGE_JPEG,
39 .label = LABEL_IMAGE_PICTURE
40 };
41
42 /* Profile for image media class content of high resolution */
43 static dlna_profile_t jpeg_lrg = {
44 .id = "JPEG_LRG",
45 .mime = MIME_IMAGE_JPEG,
46 .label = LABEL_IMAGE_PICTURE
47 };
48
49 /* Profile for image thumbnails */
50 static dlna_profile_t jpeg_tn = {
51 .id = "JPEG_TN",
52 .mime = MIME_IMAGE_JPEG,
53 .label = LABEL_IMAGE_ICON
54 };
55
56 /* Profile for small icons */
57 static dlna_profile_t jpeg_sm_ico = {
58 .id = "JPEG_SM_ICO",
59 .mime = MIME_IMAGE_JPEG,
60 .label = LABEL_IMAGE_ICON
61 };
62
63 /* Profile for large icons */
64 static dlna_profile_t jpeg_lrg_ico = {
65 .id = "JPEG_LRG_ICO",
66 .mime = MIME_IMAGE_JPEG,
67 .label = LABEL_IMAGE_ICON
68 };
69
70 static const struct {
71 dlna_profile_t *profile;
72 int max_width;
73 int max_height;
74 } jpeg_profiles_mapping[] = {
75 { &jpeg_sm_ico, 48, 48 },
76 { &jpeg_lrg_ico, 120, 120 },
77 { &jpeg_tn, 160, 160 },
78 { &jpeg_sm, 640, 480 },
79 { &jpeg_med, 1024, 768 },
80 { &jpeg_lrg, 4096, 4096 },
81 { NULL, 0, 0 }
82 };
83
84 static dlna_profile_t *
85 probe_jpeg (AVFormatContext *ctx,
86 dlna_container_type_t st,
87 av_codecs_t *codecs)
88 {
89 int i;
90
91 if (!stream_ctx_is_image (ctx, codecs, st))
92 return NULL;
93
94 /* check for JPEG compliant codec */
95 if (codecs->vc->codec_id != CODEC_ID_MJPEG &&
96 codecs->vc->codec_id != CODEC_ID_MJPEGB &&
97 codecs->vc->codec_id != CODEC_ID_LJPEG &&
98 codecs->vc->codec_id != CODEC_ID_JPEGLS)
99 return NULL;
100
101 for (i = 0; jpeg_profiles_mapping[i].profile; i++)
102 if (codecs->vc->width <= jpeg_profiles_mapping[i].max_width &&
103 codecs->vc->height <= jpeg_profiles_mapping[i].max_height)
104 return jpeg_profiles_mapping[i].profile;
105
106 return NULL;
107 }
108
109 dlna_registered_profile_t dlna_profile_image_jpeg = {
110 .id = DLNA_PROFILE_IMAGE_JPEG,
111 .class = DLNA_CLASS_IMAGE,
112 .extensions = "jpg,jpe,jpeg",
113 .probe = probe_jpeg,
114 .next = NULL
115 };