Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

ニコニコ動画iPhoneアプリの作り方

kenmaz
October 12, 2011

 ニコニコ動画iPhoneアプリの作り方

2011/10/12に開催された「スマートフォン2011春」での講演資料です。
http://expo.nikkeibp.co.jp/sma/spring/

kenmaz

October 12, 2011
Tweet

More Decks by kenmaz

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • দલ݈ଠ࿠ (id: kenmaz) • υϫϯΰ χίχίࣄۀຊ෦ اը։ൃ෦ χίχίiPhone

    ։ൃϦʔμʔ • 2010/06 த్ೖࣾ • લ৬͸େखϝʔΧʔܥSIerͰݚڀ։ൃ
  2. • ύϥύϥອըͷΑ͏ʹJPEGΛ̍ίϚͣͭ࠶ੜͯ͠ಈ ըͬΆ͘ݟͤΔ • ө૾ = JPEGɺԻ੠ = ADPCM •

    ಈըσʔλΛ̍ඵ (One-Sec)͝ͱʹ෼ׂɾύέοτ Խ ը૾ ը૾ ը૾ ը૾ ը૾ Ի੠ ̍ඵ෼ ը૾ ը૾ ը૾ Ի੠ ̍ඵ෼ ૾ ը૾ ը૾ ը૾ Ի੠ ̍ඵ෼ osecܗࣜʁ ͓ͤͪ
  3. دΓಓɿ̍෼Ͱ෼͔Δಈը ܗࣜ • mp4 : ίϯςφϑΥʔϚοτ • H.264 : ϏσΦίʔσοΫ

    • AAC : ΦʔσΟΦίʔσοΫ mp4 H.264 ϏσΦ AAC ΦʔσΟΦ
  4. دΓಓɿ̍෼Ͱ෼͔Δಈը ܗࣜ ίϯςφ ϑΥʔϚοτ mp4, m4v, flv, f4v, swf, avi,

    mov, 3gpp, webm ϏσΦ ίʔσοΫ H.264 (MPEG4-AVC), H.263, On2 VP6, VP8, Theora, MPEG-1/2, WMV ΦʔσΟΦ ίʔσοΫ AAC, MP3, ADPCM, Nellymoser, Speex, Apple Lossless, Vorbis, WMA
  5. ໰୊̍. ࠶ੜՄೳͳಈըܗ ࣜ • iPhoneͰ࠶ੜՄೳͳܗࣜ • ಈըίʔσοΫɿH.264 • Ի੠ίʔσοΫɿmp3/AAC •

    Ϣʔβ͔Β౤ߘ͞ΕΔಈըܗࣜ͸ଟछଟ༷ (flv/mp4/ DivX/MPEG1,2/WMV..) • iPhoneͰ࠶ੜͰ͖ͳ͍Մೳੑ͕͋Δ ౤ߘ͞Εͨಈը͸αʔόαΠυͰશͯH.264/ AACͰ࠶Τϯίʔυ͢Δ͜ͱʹͨ͠
  6. ίϝϯτදࣔ • ಈը্ʹίϝϯτΛॏͶͯදࣔ • ίϝϯτʹχίಈͷΩϞ • PC൛ΑΓ׈Β͔ͳදࣔʂ • PC൛ɿҰఆִؒͰίϝϯτදࣔҐஔΛͣΒͯ͠ඳ ը

    • iPhone൛ɿCoreAnimation FrameworkΛ࢖ͬͯίϝ ϯτඳըΛGPUʹ͓·͔ͤ • σϞ wwwwww wwwwwwww ͜Ε͸ͻͲ͍w Ωλʔʔʔʔʔʔ
  7. CoreAnimationͰίϝϯτඳըΛψϧψϧ [comment posX:480.0]; [UIView beginAnimations:@"comment" context:NULL]; [UIView setAnimationDuration:4.0f]; [UIView setAnimationCurve:

    UIViewAnimationCurveLinear]; [comment posX: -comment.width]; [UIView commitAnimations]; wwwww 480px wwwww 480.0 0.0 120px -120.0 600.0 ̐ඵ
  8. • ࢹௌػೳ • ௿ը࣭Ϟʔυ • ߴը࣭Ϟʔυ • ์ૹػೳ • iPhone͔Βੜ์ૹΛ഑৴

    ओͳػೳ ϓϨϛΞϜձһ +WiFi઀ଓ࣌ͷΈ ϓϨϛΞϜձһ ͷΈ
  9. RTMP (Real Time Messaging Protocol) • ಈըɾԻ੠ͷϥΠϒετϦʔϛϯάͷͨΊͷ ϓϩτίϧ • Adobe͕࢓༷Λࡦఆ

    • FlashϓϨΠϠʔ౳Ͱ࠾༻͞Ε͍ͯΔ • χίੜ(PC)͸શ໘తʹRTMPΛ࠾༻ • iPhoneɾΨϥέʔ͸RTMPͷ௚઀࠶ੜ͸ෆՄ
  10. ̎ํࣜͷൺֱ • ΫϥΠΞϯταΠυѹॖํࣜ • ௕ॴɿதܧαʔόʔ͕ෆཁ • ୹ॴɿiPhone಺Ͱѹॖ͢ΔͷͰCPUෛՙߴ • αʔόʔαΠυѹॖํࣜ •

    ௕ॴɿiPhone͸Χϝϥө૾ΛΩϟϓνϟ͠ૹ ৴͢Δ͚ͩͳͷͰCPUෛՙ௿ • ୹ॴɿதܧαʔόʔ͕ඞཁ
  11. αʔόʔαΠυѹॖํࣜΛ࠾༻ • ΫϥΠΞϯταΠυѹॖํࣜ • ௕ॴɿதܧαʔόʔ͕ෆཁ • ୹ॴɿiPhone಺Ͱѹॖ͢ΔͷͰCPUෛՙߴ • αʔόʔαΠυѹॖํࣜ •

    ௕ॴɿiPhone͸Χϝϥө૾ΛΩϟϓνϟ͠ૹ ৴͢Δ͚ͩͳͷͰCPUෛՙ௿ • ୹ॴɿதܧαʔόʔ͕ඞཁ iPhone3GS΍iPod TouchͳͲ CPUੑೳͷ௿͍୺຤Ͱ΋ ࢖͑ΔΑ͏ʹ͍ͨ͠ʂ
  12. Appleͷن໿ • iOSΞϓϦΛ։ൃ͢Δ্ͰAppleͷن໿ ΛकΔ͜ͱ͸ඞਢ • App Store Review Guidelines (※1)

    • HTTP Live Streaming Overview (※2) ※1 ) http://developer.apple.com/appstore/resources/approval/guidelines.html ※2 ) http://developer.apple.com/library/ios/#documentation/NetworkingInternet/ Conceptual/StreamingMediaGuide/Introduction/Introduction.html
  13. HTTP Live Streaming ৄࡉ • HTTP͚ͩͰٖࣅతʹϥΠϒετϦʔϛϯά Λ࣮ݱ͢Δϓϩτίϧ • Apple͕࢓༷Λࡦఆ •

    IETFͷΠϯλʔωοτυϥϑτͱͯ͠ఏग़ • iPhone,QuickTimeͳͲͰ࠾༻ • Adobe FMS͕HLSΛαϙʔτ͢Δ༧ఆ(!)
  14. HTTPαʔόʔ (ApacheͳͲ) HTTP Live Streaming ͷ࢓૊Έ H.264 ಈըϑΝΠϧ sample_0001.ts sample_0002.ts

    sample_0003.ts ಈըϑΝΠϧΛ 10ඵ͝ͱʹ෼ׂ #EXTM3U #EXT-X-TARGETDURATION:10 #EXTINF:10, sample_0001.ts #EXTINF:10, sample_0002.ts #EXTINF:10, sample_0003.ts ϓϨΠϦετ(m3u8) Λੜ੒ ϓϨΠϦετͲ͓Γʹ ࿈ଓ࠶ੜ
  15. HTTPαʔόʔ (ApacheͳͲ) HTTP Live Streaming ͷ࢓૊Έ sample_0001.ts sample_0002.ts sample_0003.ts ө૾σʔλΛ

    10ඵ͝ͱʹ෼ׂ #EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE: 0 #EXTINF:10, sample_0001.ts #EXTINF:10, sample_0002.ts #EXTINF:10, sample_0003.ts ϓϨΠϦετ(m3u8) ͕ಈతʹߋ৽͞ΕΔ ϓϨΠϦετͲ͓Γʹ ࿈ଓ࠶ੜ
  16. HLSͷಛ௃ • ଳҬ෯ʹԠͨ͡ը࣭ࣗಈ੾Γସ͑ • ଳҬ͕ࡉͯ͘΋շదʹಈըΛࢹௌͰ͖Δ ௿ը࣭ಈը sample_0001.ts sample_0002.ts sample_0003.ts ߴը࣭ಈը

    sample_0001.ts sample_0002.ts sample_0003.ts ௨৴ঢ়گ͕ ྑ͍࣌ ௨৴ঢ়گ͕ ѱ͍࣌ ଳҬ෯ʹԠͯࣗ͡ಈ੾׵͑
  17. ·ͱΊ • χίಈ / χίੜiPhoneΞϓϦΛࢧ͑Δٕज़ʹ͍ͭͯ঺ հ • ಈը΍ԻָͳͲϝσΟΞίϯςϯπΛѻ͏ΞϓϦΛ։ ൃ͢Δ৔߹͸ɺΞοϓϧͷن໿ʹ஫ҙ͢Δඞཁ͕͋Δ •

    iPhoneΞϓϦͷ৹ࠪίετΛճආ͢Δʹ͸෦෼తʹ webԽ͢Δͷ͕༗ޮ • χίχίಈըͰ΋εϚʔτϑΥϯͷॏཁੑ͸࣮֬ʹߴ ·͖͍ͬͯͯΔ