PageRenderTime 92ms CodeModel.GetById 39ms app.highlight 50ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/update-engine/externals/gdata-objectivec-client/Source/Media/GDataMediaContent.m

http://macfuse.googlecode.com/
Objective C | 190 lines | 125 code | 29 blank | 36 comment | 2 complexity | 1d42e288a4aeec8ed2c813383bfb499a MD5 | raw file
  1/* Copyright (c) 2007 Google Inc.
  2*
  3* Licensed under the Apache License, Version 2.0 (the "License");
  4* you may not use this file except in compliance with the License.
  5* You may obtain a copy of the License at
  6*
  7*     http://www.apache.org/licenses/LICENSE-2.0
  8*
  9* Unless required by applicable law or agreed to in writing, software
 10* distributed under the License is distributed on an "AS IS" BASIS,
 11* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12* See the License for the specific language governing permissions and
 13* limitations under the License.
 14*/
 15
 16//
 17//  GDataMediaContent.m
 18//
 19
 20#if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_PHOTOS_SERVICE \
 21  || GDATA_INCLUDE_YOUTUBE_SERVICE
 22
 23#import "GDataMediaContent.h"
 24#import "GDataMediaGroup.h"
 25
 26static NSString* const kURLAttr = @"url";
 27static NSString* const kFileSizeAttr = @"fileSize";
 28static NSString* const kTypeAttr = @"type";
 29static NSString* const kMediumAttr = @"medium";
 30static NSString* const kIsDefaultAttr = @"isDefault";
 31static NSString* const kExpressionAttr = @"expression";
 32static NSString* const kBitrateAttr = @"bitrate";
 33static NSString* const kFramerateAttr = @"framerate";
 34static NSString* const kSamplingRateAttr = @"samplingrate";
 35static NSString* const kChannelsAttr = @"channels";
 36static NSString* const kDurationAttr = @"duration";
 37static NSString* const kHeightAttr = @"height";
 38static NSString* const kWidthAttr = @"width";
 39static NSString* const kLangAttr = @"lang";
 40
 41@implementation GDataMediaContent
 42// media:content element
 43//
 44//  <media:content 
 45//    url="http://www.foo.com/movie.mov" 
 46//    fileSize="12216320" 
 47//    type="video/quicktime"
 48//    medium="video"
 49//    isDefault="true" 
 50//    expression="full" 
 51//    bitrate="128" 
 52//    framerate="25"
 53//    samplingrate="44.1"
 54//    channels="2"
 55//    duration="185" 
 56//    height="200"
 57//    width="300" 
 58//    lang="en" />
 59//
 60// http://search.yahoo.com/mrss
 61
 62
 63+ (NSString *)extensionElementURI       { return kGDataNamespaceMedia; }
 64+ (NSString *)extensionElementPrefix    { return kGDataNamespaceMediaPrefix; }
 65+ (NSString *)extensionElementLocalName { return @"content"; }
 66
 67+ (GDataMediaContent *)mediaContentWithURLString:(NSString *)urlString {
 68  
 69  GDataMediaContent *obj = [self object];
 70  [obj setURLString:urlString];
 71  return obj;
 72}
 73
 74- (void)addParseDeclarations {
 75  
 76  NSArray *attrs = [NSArray arrayWithObjects: 
 77                    kURLAttr, kFileSizeAttr, kTypeAttr, 
 78                    kMediumAttr, kIsDefaultAttr, kExpressionAttr, 
 79                    kBitrateAttr, kFramerateAttr, kSamplingRateAttr,
 80                    kChannelsAttr, kDurationAttr, kHeightAttr, kWidthAttr,
 81                    kLangAttr, nil];
 82  
 83  [self addLocalAttributeDeclarations:attrs];
 84}
 85
 86#pragma mark -
 87
 88- (NSString *)URLString {
 89  return [self stringValueForAttribute:kURLAttr];
 90}
 91- (void)setURLString:(NSString *)str {
 92  [self setStringValue:str forAttribute:kURLAttr];
 93}
 94
 95- (NSNumber *)fileSize {
 96  return [self longLongNumberForAttribute:kFileSizeAttr];
 97}
 98- (void)setFileSize:(NSNumber *)num {
 99  [self setStringValue:[num stringValue] forAttribute:kFileSizeAttr];
100}
101
102- (NSString *)type {
103  return [self stringValueForAttribute:kTypeAttr];
104}
105- (void)setType:(NSString *)str {
106  [self setStringValue:str forAttribute:kTypeAttr];
107}
108
109- (NSString *)medium {
110  return [self stringValueForAttribute:kMediumAttr];
111}
112- (void)setMedium:(NSString *)str {
113  [self setStringValue:str forAttribute:kMediumAttr];
114}
115
116- (NSNumber *)isDefault {
117  BOOL flag = [self boolValueForAttribute:kIsDefaultAttr defaultValue:NO];
118  return flag ? [NSNumber numberWithBool:flag] : nil; 
119}
120- (void)setIsDefault:(NSNumber *)num {
121  BOOL flag = [num boolValue];
122  [self setBoolValue:flag defaultValue:NO forAttribute:kIsDefaultAttr];
123}
124
125- (NSString *)expression {
126  return [self stringValueForAttribute:kExpressionAttr];
127}
128- (void)setExpression:(NSString *)str {
129  [self setStringValue:str forAttribute:kExpressionAttr];
130}
131
132- (NSDecimalNumber *)bitrate {
133  return [self decimalNumberForAttribute:kBitrateAttr];
134}
135- (void)setBitrate:(NSDecimalNumber *)num {
136  [self setDecimalNumberValue:num forAttribute:kBitrateAttr];
137}
138
139- (NSDecimalNumber *)framerate {
140  return [self decimalNumberForAttribute:kFramerateAttr];
141}
142- (void)setFramerate:(NSDecimalNumber *)num {
143  [self setDecimalNumberValue:num forAttribute:kFramerateAttr];
144}
145
146- (NSDecimalNumber *)samplingrate {
147  return [self decimalNumberForAttribute:kSamplingRateAttr];
148}
149- (void)setSamplingrate:(NSDecimalNumber *)num {
150  [self setDecimalNumberValue:num forAttribute:kSamplingRateAttr];
151}
152
153- (NSNumber *)channels {
154  return [self intNumberForAttribute:kChannelsAttr];
155}
156- (void)setChannels:(NSNumber *)num {
157  [self setStringValue:[num stringValue] forAttribute:kChannelsAttr];
158}
159
160- (NSNumber *)duration {
161  return [self intNumberForAttribute:kDurationAttr];
162}
163- (void)setDuration:(NSNumber *)num {
164  [self setStringValue:[num stringValue] forAttribute:kDurationAttr];
165}
166
167- (NSNumber *)height {
168  return [self intNumberForAttribute:kHeightAttr];
169}
170- (void)setHeight:(NSNumber *)num {
171  [self setStringValue:[num stringValue] forAttribute:kHeightAttr];
172}
173
174- (NSNumber *)width {
175  return [self intNumberForAttribute:kWidthAttr];
176}
177- (void)setWidth:(NSNumber *)num {
178  [self setStringValue:[num stringValue] forAttribute:kWidthAttr];
179}
180
181- (NSString *)lang {
182  return [self stringValueForAttribute:kLangAttr]; 
183}
184- (void)setLang:(NSString *)str {
185  [self setStringValue:str forAttribute:kLangAttr];
186}
187
188@end
189
190#endif // #if !GDATA_REQUIRE_SERVICE_INCLUDES || GDATA_INCLUDE_*_SERVICE