Thursday, March 27, 2014

Week12 Blog8

Progress I made
  1. Following the discussions in last week's meeting, I changed the alert sound from the system notification sound to an external sound, played using pygame.
  2. Squashed and rebased all commits
  3. Tested auto-recording using the test cases below
 Test cases:

- Empty case
  • No talks in database
- "No talks available" dialog box 
  • talk A, has room number, start time already passed
  • talk A, no room number, start time later than current time
  • talk A, room 123, set to a different later date
  • talks A B C, all have same room number, all with starting times that have already passed
  • talks A B C, A B have same room numbers, C has different room number, all with starting times that have already passed
  • talks A B C, A B have same room numbers, C has different room number, A B start time passed, C start time later than current time, but room number selected in the recording interface is the room for talk A
- "No room selected" dialog box (room field empty in recording interface)
  • talk A, has room number, start time later than current time
- One talk available (room 123 selected)
  • talk A, room 123, start time later than current time
  • talks A B C, A B have no room number, C room 123, all start time later than current time
  • talks A B C, A C room 456, B room 123, all start time later than current time
  • talks A B, all in room 123, B's start time between start and end time of A (need to fix!) 
- More than one talk available (room 123 selected)
  • talks A B C, A C room 123, B room 456, all start time later than current time
  • talks A B C, all in room 123, A C start time later than current time, B start time passed
  • talks A B C, all in room 123, all start time later than current time
- Stop auto-record (room 123 selected)
  • talks A B C, all in room 123, all start time later than current time,press "Stop Auto-Record" before recording starts
  • talks A B C, all in room 123, all start time later than current time,press "Stop Auto-Record" in the middle of a recording
- Countdown display + flash screen + alert sound
  • talk A, room 123, set start time to 2 hours after current time
  • talk A, room 123, set start time to 3 minutes after current time
  • talk A, room 123, set start time to 1.5 minutes after current time
  • talk A, room 123, set start time to 20 seconds after current time
  • talk A, room 123, set duration to 3 minutes 10 seconds
  • talk A, room 123, set duration to 1.5 minutes
  • talk A, room 123, set duration to 20 seconds
- Length of recording (check the talk is recorded properly and saved in the video directory)
  • talk A, room 123, set duration to 1 minute
  • talk A, room 123, set duration to 10 seconds
Also check that when in auto-record mode, all buttons in recording interface are disabled, and the Stop Auto-Record button is pressed down.

Plans for next week
  • Fix problem found by test case above
  • Find out the alert sound's license
  • Try to change from using pygame to QSound
  • Edit, polish, and finish the project proposal
  • Request for code review and make any last modifications to the files in the pull request

Problems
None. Thanks to Dennis and Thanh, finally figured out an easier way to rebase to master!


Saturday, March 22, 2014

UCOSP Reflections

This semester, I joined the Freeseer project as part of the UCOSP project course. The project was a new challenge for me, but at the same time, it was very enjoyable. Now the term has almost come to an end, and I'd like to share some thoughts about this valuable experience.


About Freeseer & My Role In It

Freeseer is a free, open source, cross-platform application used to capture presentations. It has been used at many open source conferences to record hundreds of talks. The way Freeseer works is simple: first, store information about the talks you want to record, including the title, event, speaker, room, date and start time. Next, set up the external cables and connections for recording. Then, select the current talk to record, and Freeseer will capture the speaker's laptop screen along with the presentation talk.

My project this term was to implement a new auto-recording feature for Freeseer. This feature detects when a talk is starting/ending, and automatically records it. This would allow a laptop doing the recording to automatically record all the talks in a room without the need of a volunteer to monitor it. For this feature to work, we first store an additional end time of a talk on top of the start time. Then, if the user presses the auto-record button, we search for all the talks starting at or after the current computer time, in the specified room. If no talks satisfy these conditions, a dialog box pops up, informing the user that no such talks are available. Otherwise, we enter a fullscreen mode that displays the title and speaker of the next talk to be recorded, and the countdown until the start of the recording. As the time to start recording approaches, the screen flashes, and an alert sound plays to remind the speaker to get ready. During the recording, there is a similar countdown informing the speaker how much time he/she has left until the end of the recording. After this recording, the cycle repeats again.


Reflections About My Project

It was really fun to implement the auto-recording feature because, not only did I get to familiarize myself with the existing code in the Freeseer repository, but I also got to learn lots of cool new techniques, such as how to use PyQt4's QTimer to simulate a countdown, how to show changing countdown display messages, how to use system notification sounds as alert sounds, etc.

While doing the project, I've also encountered some roadblocks along the way. There were times when I spent a whole day trying to find a bug in a function, carefully debugging and showing the state of the variables after every line, and still hadn't found the source of the problem. Then, in my devastation, I finally switched to another method to implement this function, and TA-DA! It worked! Because of these kind of failures, I have learned to become more flexible with programming.

We were required to keep blog posts about the progress we made each week, what we planned to do next week, and any issues/concerns we had. At first this seemed like a burden, but soon, I found keeping blog posts very helpful! Since I also had to think about assignments/lectures for other courses, it was impossible to work on Freeseer every day of the week. So, when I returned to work on the project one week later, I could barely remember anything from last week, or what I should be working on next. Thus I relied heavily on my blog posts to keep me on track. It was also quite easy to write the post! I only needed to keep a note of what I just did after I completed each task, while it was still fresh in my mind.


Tips For Students Doing UCOSP Next Year

  • This semester, the code sprint was scheduled to be later than in previous years, so the students were less motivated to start working right away, and the pace was slower than usual. However, it's a good idea to start early because when doing programming, it generally takes longer than you think to finish something. Furthermore, the earlier you start to work on the project, the more questions you may have for the mentors at the code sprint, and thus the more productive you will be at the code sprint.
  • It's always hard to start the project because students would at first feel overwhelmed by the large existing code base, and do not know where to start. The advice from one of the mentors that really helped me was, instead of stressing over the right place to start, just start somewhere. Try running the application, play around with the code, and you'll naturally become more familiar with the code.
  • The code sprint is a place to meet your team members and mentors, as well as teams from other UCOSP projects. This is your chance to communicate face-to-face with your team, and ask any questions you may have for the mentors. Of course, most of the time is spent on coding, so please bring your laptop! (This may sound like an obvious suggestion, but I didn't really know what the code sprint was about before going there, or whether there would be computers for us to work on. Now that I think about it, everyone is working on different projects, which have different installation requirements, so of course we would need our own laptops if we want to work on our projects! Hahaha...)
Well, that's all from me for now. I really had a great time taking this project course, learning, contributing, and getting to know some very nice people, all at the same time. I hope future UCOSP students will enjoy this precious experience, just as I did! 



Thursday, March 20, 2014

Week11 Blog7

Progress I made
    • This week, most of the time is spent on researching how to play sound using Python/Pyqt4. The methods I've tried include QSound, Phonon, PyGraphics' sound_media.py, pygame, and finally system alert sound.
    1. QSound simply did not play a sound on Ubuntu Linux.
    2. Phonon did play the sound correctly, except that it sits in the event loop and won't exit. So I added some signals code and '''app.connect(media, SIGNAL("finished()"), app, SLOT("quit()"))''' to make it quit after the sound file finished playing. Now the program exited, but gives me a segmentation fault.
    3. PyGraphics' sound_media.py loads and plays sounds well when I try it in the python shell, but if I move the code to a py file, then run it, it did't play a sound.
    4. After attempting to fix the issues above and failing, I tried pygame. Referencing the code snippets from http://stackoverflow.com/questions/7746263/how-play-mp3-with-pygame I got the reminder sound to work! However, asking around on IRC, a mentor informed me that generally we should not store external binary data in source control, and suggested using system notification sounds instead.
    5. So eventually, I switched to using the system alert sound. I found that the code is very simple. There are advantages and drawbacks for this method though. The advantage is that we don't need to store an external sound file. The drawback are, 1: in order for the sound to work, we need to ensure that each laptop doing the recording does not have the system alert sound disabled. 2: the system alert sounds are different across different platforms, so some of them may not sound like alerts, some of the alert sounds may have volumes that are hard to hear, etc.
    • Last week I speculated that the countdown display text may have been set to an absolution position, which is undesirable. However, my investigation into the issue shows that I did indeed use relative position (for example http://zetcode.com/gui/pyqt4/layoutmanagement/).
    • Reset the alignment of the display text to be centred.

    Plans for next week
    • Fully test the auto-recording feature, by designing and implementing more comprehensive test cases.

    Problems
    None.


    Thursday, March 13, 2014

    Week10 Blog6

    Progress I made
    • Researched how to flash the countdown screen and countdown text. Found some code for flashing the text using QPropertyAnimation: https://gist.github.com/justinfx/5318065. But when I tried using this method, it keeps giving me "TypeError: unable to convert a Python 'QBrush' object to a C++ 'QColor' instance". So in the end, I decided to implement it my own way, which is to use another timer to keep track of when to change the colour of the display.
    • Following others' advice, made changes to the display: 1. If there's more than 2 minutes remaining, display only the minutes, e.g. "X min.", otherwise display minutes and seconds, e.g. "01:25"; 2. Flash the screen at 1 minute and at 30 seconds, using inverted screen colours; 3. When there's 10 seconds left, change countdown colour to red.
    • Looked over mentors' code reviews on Github and made some minor changes accordingly

    Plans for next week
    •  I found that the display text size I set for the countdown string shows properly on my computer, but if I show it on a small computer, the proportion isn't right. I need to figure out a way to show the relative position instead of setting an absolute size.
    • Research and implement reminder sound function before the starting the recording of the current talk.

    Problems
    • It seems that I don't understand what "rebase" does in git. On Freeseer's contributor guide, it says "Rebase frequently to incorporate changes from upstream". When I did that, it gave me all the merge conflicts, starting from the first commit I made in my pull request. So after an hour of solving the merge conflicts and pushing the unconflicted version into my Github pull request, I did "rebase" again to make sure I got the latest changes. But this put me right back to where I started: it again showed me all the merge conflicts starting from the first commit... I think I really need to go look up what "rebase" is before doing anything else.

    Thursday, March 6, 2014

    Week9 Blog5

    Progress I made
    • Countdown display now shows the appropriate 00:00:00 when the time is up (the problem from last week)
    • Implemented the stop auto recording cases. Case1: there are no more talks to record and no user interruption, exit the auto-record screen after the last talk. Case2: auto-recording isn't finished, but user decides to end auto record by pressing the "Stop auto-record". Then exit countdown screen and stop recording right away.
    • Disabled all other buttons while in auto recording mode, and returned them to original position after auto recording is done
    • Added message boxes that appear when: 1. no room is selected for auto-recording; 2. there are no upcoming talks to auto-record

    Plans for next week
    • Research how to flash the countdown screen and add reminder sound for reminding the presenter when then auto-record will stop recording 
    • Design the reminder functions so that it the presenter can easily see the countdown and finish the talk before the time runs out
    • Implement the reminder function several times before the end of the recording

    Problems

    None.