I would argue that the most important of these three is family. I believe this because the individual is in contact with the family more than with the media or school friends during the first years of life. These years are sufficient to build a foundation for the way in which the person will understand what it means to be male or female in their society.
By the time a person starts to school, they have spent a huge amount of time around their parents. They have seen what sorts of sex roles their parents play in their own family. Their family has taught them the basics of how someone of their sex is supposed to act. For example, a father might call a son his "little man" and encourage him to be tough while he might call his daughter "princess" and encourage her to be loving. These kinds of behaviors will socialize the child and help them construct their ideas of gender roles before they are exposed much to school or media.