Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(810)

Side by Side Diff: examples/albumart.c

Issue 2364793002: Revert "Uprev libmtp to 1.1.12" (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libmtp@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « examples/Makefile.in ('k') | examples/albums.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * \file albumart.c 2 * \file albumart.c
3 * Example program to send album art. 3 * Example program to send album art.
4 * 4 *
5 * Copyright (C) 2006 Andy Kelk <andy@mopoke.co.uk> 5 * Copyright (C) 2006 Andy Kelk <andy@mopoke.co.uk>
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 uint32_t *ids = NULL; 48 uint32_t *ids = NULL;
49 uint32_t *tmp = NULL; 49 uint32_t *tmp = NULL;
50 uint64_t filesize; 50 uint64_t filesize;
51 char *imagedata = NULL; 51 char *imagedata = NULL;
52 char *albumname = NULL; 52 char *albumname = NULL;
53 char *path = NULL; 53 char *path = NULL;
54 char *rest; 54 char *rest;
55 struct stat statbuff; 55 struct stat statbuff;
56 uint32_t storageid = 0; 56 uint32_t storageid = 0;
57 uint32_t parentid = 0; 57 uint32_t parentid = 0;
58 int ret;
59 58
60 fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n"); 59 fprintf(stdout, "libmtp version: " LIBMTP_VERSION_STRING "\n\n");
61 60
62 while ( (opt = getopt(argc, argv, "dhn:i:s:p:")) != -1 ) { 61 while ( (opt = getopt(argc, argv, "dhn:i:s:p:")) != -1 ) {
63 switch (opt) { 62 switch (opt) {
64 case 'h': 63 case 'h':
65 usage(); 64 usage();
66 case 'd': 65 case 'd':
67 LIBMTP_Set_Debug(LIBMTP_DEBUG_PTP | LIBMTP_DEBUG_DATA); 66 LIBMTP_Set_Debug(LIBMTP_DEBUG_PTP | LIBMTP_DEBUG_DATA);
68 break; 67 break;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 117
119 #ifdef __WIN32__ 118 #ifdef __WIN32__
120 if ( (fd = open(path, O_RDONLY|O_BINARY) == -1) ) { 119 if ( (fd = open(path, O_RDONLY|O_BINARY) == -1) ) {
121 #else 120 #else
122 if ( (fd = open(path, O_RDONLY)) == -1) { 121 if ( (fd = open(path, O_RDONLY)) == -1) {
123 #endif 122 #endif
124 printf("Couldn't open image file %s (%s)\n",path,strerror(errno)); 123 printf("Couldn't open image file %s (%s)\n",path,strerror(errno));
125 return 1; 124 return 1;
126 } 125 }
127 else { 126 else {
128 ret = read(fd, imagedata, filesize); 127 read(fd, imagedata, filesize);
129 if (ret == -1) perror("read");
130 close(fd); 128 close(fd);
131 } 129 }
132 130
133 LIBMTP_Init(); 131 LIBMTP_Init();
134 device = LIBMTP_Get_First_Device(); 132 device = LIBMTP_Get_First_Device();
135 if (device == NULL) { 133 if (device == NULL) {
136 printf("No devices.\n"); 134 printf("No devices.\n");
137 return 0; 135 return 0;
138 } 136 }
139 137
140 LIBMTP_filesampledata_t *albumart = LIBMTP_new_filesampledata_t(); 138 LIBMTP_filesampledata_t *albumart = LIBMTP_new_filesampledata_t();
141 albumart->data = imagedata; 139 albumart->data = imagedata;
142 albumart->size = filesize; 140 albumart->size = filesize;
143 albumart->filetype = LIBMTP_FILETYPE_JPEG; 141 albumart->filetype = LIBMTP_FILETYPE_JPEG;
144 142
145 LIBMTP_album_t *album = LIBMTP_new_album_t(); 143 LIBMTP_album_t *album = LIBMTP_new_album_t();
146 album->name = albumname; 144 album->name = albumname;
147 album->no_tracks = idcount; 145 album->no_tracks = idcount;
148 album->tracks = ids; 146 album->tracks = ids;
149 album->parent_id = parentid; 147 album->parent_id = parentid;
150 album->storage_id = storageid; 148 album->storage_id = storageid;
151 149 int ret = LIBMTP_Create_New_Album(device,album);
152 ret = LIBMTP_Create_New_Album(device,album);
153 if (ret == 0) { 150 if (ret == 0) {
154 ret = LIBMTP_Send_Representative_Sample(device,album->album_id, albumart); 151 ret = LIBMTP_Send_Representative_Sample(device,album->album_id, albumart);
155 if (ret != 0) { 152 if (ret != 0) {
156 printf("Couldn't send album art\n"); 153 printf("Couldn't send album art\n");
157 LIBMTP_Dump_Errorstack(device); 154 LIBMTP_Dump_Errorstack(device);
158 LIBMTP_Clear_Errorstack(device); 155 LIBMTP_Clear_Errorstack(device);
159 } 156 }
160 } 157 }
161 else { 158 else {
162 printf("Couldn't create album object\n"); 159 printf("Couldn't create album object\n");
163 LIBMTP_Dump_Errorstack(device); 160 LIBMTP_Dump_Errorstack(device);
164 LIBMTP_Clear_Errorstack(device); 161 LIBMTP_Clear_Errorstack(device);
165 } 162 }
166 163
167 LIBMTP_destroy_filesampledata_t(albumart); 164 LIBMTP_destroy_filesampledata_t(albumart);
168 LIBMTP_destroy_album_t(album); 165 LIBMTP_destroy_album_t(album);
169 166
170 LIBMTP_Release_Device(device); 167 LIBMTP_Release_Device(device);
171 printf("OK.\n"); 168 printf("OK.\n");
172 return 0; 169 return 0;
173 } 170 }
174 171
OLDNEW
« no previous file with comments | « examples/Makefile.in ('k') | examples/albums.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698